I got an issue in trying to limit the date. With setting the date like that self.datePicker.maximumDate = [NSDate date];
it is only grey the date after now but enable the user to select a date after this maximum date.
So When the picker value changed I compare the selected date if up than the current date I edit it.
If I use both solutions I got weird behaviour, any idea ?
- (IBAction)pickerValueChanged:(id)sender {
dispatch_async(dispatch_get_main_queue(), ^{
UIDatePicker *datePicker = (UIDatePicker *)sender;
if ([self.datePicker.date compare:[NSDate date]] == NSOrderedDescending) {
datePicker.date = [NSDate date];
}
});
}
This function is triggered when the date value from the date picker did change. If I set a minimum and a maximum date I got a weird behaviour. Any idea?
EDIT:
- http://youtu.be/GX0pbyjBC-U without setting
self.datePicker.maximumDate = [NSDate date];
- http://youtu.be/U8hYVSfKRZ4 with both