Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Past Date in UIDatePicker in IPhone Objective C

I am new to Objective C and IPhone development.

I am using a UIDatePicker in my IPhone Application and my requirement is to allow the user to choose the future date only from the DatePicker.

To do this i want to disable past date & time in DatePicker only instead of putting a compare validation in the code.

Is this possible or there is an option to disable the past date in the DatePicker control itself.

like image 339
user658442 Avatar asked Mar 14 '11 08:03

user658442


2 Answers

Did you try this

[picker setMinimumDate: [NSDate date]]; 
like image 59
visakh7 Avatar answered Oct 12 '22 20:10

visakh7


Use the following line,to disable the previous dates of an UIDatePicker.

[picker setMinimumDate: [NSDate date]]; 

The current date is displayed as shown below

enter image description here

like image 32
Madhu Avatar answered Oct 12 '22 21:10

Madhu