Add AM/PM to datepicker?

假装没事ソ 提交于 2019-12-01 18:34:53

问题


My UIDatePicker is set to UIDatePickerModeTime but on the apple documentation it says The date picker displays hours, minutes, and (optionally) an AM/PM designation. The exact items shown and their order depend upon the locale set. An example of this mode is [ 6 | 53 | PM ].. How do i add AM/PM because on my device, those aren't options and it instead uses a 24 hour clock?


回答1:


This will depend on the settings of the user. If you go to Settings -> General -> Date & Time. there is a "24-Hour" time switch, and based on that users will have the AM/PM indicator on your picker.




回答2:


Unfortunately UIDatePicker doesn't have an option for that; it always respects the device option of 12-hour or 24-hour time.

If you must have an AM/PM component you may have to go with a custom UIPickerView instead, and build an NSDate out of its components manually.




回答3:


Unfortunately UIDatePicker doesn't have an option for that; it always respects the device option of 12-hour or 24-hour time.

If you must have an AM/PM component you may have to go with a custom UIPickerView instead, and build an NSDate out of its components manually.



来源:https://stackoverflow.com/questions/4822722/add-am-pm-to-datepicker

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