How to disable only date selection in UIDatePicker

2019-02-18 08:16发布

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.

6条回答
We Are One
2楼-- · 2019-02-18 08:58

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

查看更多
Juvenile、少年°
3楼-- · 2019-02-18 09:02

Set the datePickerMode to UIDatePickerModeTime.

查看更多
相关推荐>>
4楼-- · 2019-02-18 09:05

Please try this:

datePicker.datePickerMode = UIDatePickerModeTime;

Other options are:

typedef enum {
   UIDatePickerModeTime,
   UIDatePickerModeDate,
   UIDatePickerModeDateAndTime,
   UIDatePickerModeCountDownTimer
} UIDatePickerMode;
查看更多
Ridiculous、
5楼-- · 2019-02-18 09:09

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

[self.datePicker setDatePickerMode:UIDatePickerModeTime];
查看更多
ら.Afraid
6楼-- · 2019-02-18 09:17

This will do the job

datePicker.datePickerMode = UIDatePickerModeTime;

by using Attribute inspector in the GUI you could also set it as follows enter image description here

查看更多
一夜七次
7楼-- · 2019-02-18 09:21
datePicker.datePickerMode = UIDatePickerModeTime;
查看更多
登录 后发表回答