user3725924
user3725924

Reputation: 33

Disable / Enable UIDatepicker

Is there any disable/enable function in Xcode, i have already tried the hidden function but that really doesn't suit my needs. I'm trying to turn off my UIDatepicker if a uiswitch has been toggled and if it isn't toggled i want it shown. hiding this still outputs todays date to my mail composer. Is there anyway to do this?

Upvotes: 0

Views: 2710

Answers (1)

Studiologe
Studiologe

Reputation: 187

Make sure you have a property (IBOutlet) for your UIDatepicker in your .h file then you can simply do like this:

DatePickerNamed.userInteractionEnabled = YES;
DatePickerName.userInteractionEnabled = NO;

In addition to that I also turn down the alpha value for buttons and switches, if I disable them, so there is also a visual feedback that they're inactive.

Upvotes: 7

Related Questions