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
Post a Comment