How to disable only date selection in UIDatePicker not time selection

夙愿已清 提交于 2019-12-01 05:01:29

问题


I am using UIDatePicker in my app and I want to disable only date selection in it and time selection should not be effected.

Can anyone help me with this.


回答1:


Set the datePickerMode to UIDatePickerModeTime.




回答2:


Please try this:

datePicker.datePickerMode = UIDatePickerModeTime;

Other options are:

typedef enum {
   UIDatePickerModeTime,
   UIDatePickerModeDate,
   UIDatePickerModeDateAndTime,
   UIDatePickerModeCountDownTimer
} UIDatePickerMode;



回答3:


This will do the job

datePicker.datePickerMode = UIDatePickerModeTime;

by using Attribute inspector in the GUI you could also set it as follows




回答4:


In addition to the correct answers to set it programmatically, you can also set it on your xib file , in the attributes inspector tab.




回答5:


Change the UIDatePickerMode from UIDatePickerModeDateAndTime to UIDatePickerModeTime like this...

[self.datePicker setDatePickerMode:UIDatePickerModeTime];



回答6:


datePicker.datePickerMode = UIDatePickerModeTime;


来源:https://stackoverflow.com/questions/15478666/how-to-disable-only-date-selection-in-uidatepicker-not-time-selection

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