Reputation: 980
I was wondering if there is anyway to disable a certain day or hour in a DatePicker?
I have looked around and many people suggested "UIControlEventValueChanged", I don't think thats a good idea specially if I have to disable more than 10 hours as users will get frustrated.
Is there any other way to overcome this problem? Also I don't really know what days/hours will be disabled but I receive them from my database.
Even colouring those days a different colour would be good
Upvotes: 3
Views: 2595
Reputation: 131511
The standard UIDatePicker
only lets you specify a minimum and maximum date.
If you want to use a stock date picker you'd have to set up an IBAction that would move the picker to a different value after the user picked a date in the forbidden range.
Or, as rmaddy suggests, use a standard picker view and custom code, or subclass UIPickerView
(e.g. create MyCustomFunkyDatePickerView
) and have that custom subclass implement the rules you want, either with an array of allowed date ranges or a min, max, and an array of forbidden date ranges.
Upvotes: 2