DatePicker include Year

岁酱吖の 提交于 2019-12-06 00:01:53

问题


I have dataPicker in my app implemented. But it only shows month,day,hour. How could I able to add year in the date picker. Any idea?


回答1:


datePicker.datePickerMode = UIDatePickerModeDate;

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 ].

Available in iOS 2.0 and later.

Declared in UIDatePicker.h.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDatePicker_Class/Reference/UIDatePicker.html

Also you can change from storyboard set Mode: (Refer to screenshot)




回答2:


If you want to add month, date, year as well as time, add one picker that implements the dates only using (UIDatePickerModeDate) and an additional one for the time (UIDatePickerModeTime).



来源:https://stackoverflow.com/questions/13225767/datepicker-include-year

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!