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.
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.
Set the datePickerMode
to UIDatePickerModeTime
.
Please try this:
datePicker.datePickerMode = UIDatePickerModeTime;
Other options are:
typedef enum {
UIDatePickerModeTime,
UIDatePickerModeDate,
UIDatePickerModeDateAndTime,
UIDatePickerModeCountDownTimer
} UIDatePickerMode;
This will do the job
datePicker.datePickerMode = UIDatePickerModeTime;
by using Attribute inspector in the GUI you could also set it as follows
In addition to the correct answers to set it programmatically, you can also set it on your xib file , in the attributes inspector tab.
Change the UIDatePickerMode from UIDatePickerModeDateAndTime to UIDatePickerModeTime like this...
[self.datePicker setDatePickerMode:UIDatePickerModeTime];
datePicker.datePickerMode = UIDatePickerModeTime;