I want to create a user interface for setting a date of birth. For this I choose UIDatePickerView
. Now I want to limit the dates between 01-01-1990 and the current date. It should not show future dates and past dates. I am currently using the following code:
NSDateComponents *components=[[NSDateComponents alloc] init];
[components setYear:1900];
pickerView.datePicker.minimumDate = [[NSCalendar currentCalendar] dateFromComponents:components];
pickerView.datePicker.maximumDate=[NSDate date]
It limits dates, but allows the user to scroll through future dates as well as past dates. How can I hide or avoid them?
I can see this feature in the contact application on the iPad. To go to "Contacts" → click the "+" icon on the top, then click the add birthday button.
source
share