iphone - Setting maximum date as current date in uidatepicker -


possible duplicate:
uidatepicker, setting maximum , minimum dates based on todays date

i have tried allot not able give range uidatepicker, maximum range current date. no matter picker shows values.

thanks in advance

here's possible answer setting datepicker 30 years before , 30 years after.

you can change values that..

nscalendar *calendar = [[[nscalendar alloc]  initwithcalendaridentifier:nsgregoriancalendar] autorelease]; nsdate *currentdate = [nsdate date]; nsdatecomponents *comps = [[[nsdatecomponents alloc] init] autorelease]; [comps setyear:30]; nsdate *maxdate = [calendar datebyaddingcomponents:comps todate:currentdate options:0]; [comps setyear:-30]; nsdate *mindate = [calendar datebyaddingcomponents:comps todate:currentdate options:0];  [datepicker setmaximumdate:maxdate]; [datepicker setminimumdate:mindate]; 

hope helps..


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -