NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDate *currentDate = [NSDate date];
NSDateComponents *comps = [[[NSDateComponents alloc] init] autorelease];
[comps setYear:0];
NSDate *maxDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0];
[comps setYear:-5];
NSDate *minDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0];
[datePicker setMaximumDate:maxDate];
[datePicker setMinimumDate:minDate];
聽到日期顯示當前日期的minDate和五個年度(回)MAXDATE 這是隻顯示5年.....
嘿@Matthew,將其設置爲正確答案麼!點擊複選標記。 – vfn 2010-08-30 00:02:23
它不會讓我再做2天 - 所以我會這樣做:D – 2010-08-30 09:06:07