问题
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