UIDatePicker select Month and Year

前端 未结 11 1859
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 04:00

I need a UIDatePicker for selecting Month and Year only. I checked the class reference documents. Looks like UIDatePicker is a UIView.

11条回答
  •  自闭症患者
    2020-11-27 04:14

    No, this cannot be done using the stock UIDatePicker.

    UIDatePickerModeDate

    The date picker displays months, days of the month, and years. The exact order of these items depends on the locale setting. An example of this mode is [ November | 15 | 2007 ].

    Source: UIDatePicker class reference

    I recommend customizing a UIPickerView to use two components and populating its rows with month and year symbols retrieved from NSDateFormatter.

提交回复
热议问题