小编sab*_*bir的帖子

显示8年前的datepicker并在ios中锁定ui datepicker

在我的项目中,我需要显示日期选择器18,我需要锁定80年后,所以如何在datepicker中显示这些日期可以任何人帮我在这里找到这里添加代码我的代码我打印在日志但我需要在我的日期选择器上显示,以便我如何显示

NSCalendar * gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
NSDate * currentDate = [NSDate date];
NSDateComponents * comps = [[NSDateComponents alloc] init];
[comps setYear: -18];
NSDate * minDate = [gregorian dateByAddingComponents: comps toDate: currentDate options: 0];
[comps setYear: -100];
NSDate * maxDate = [gregorian dateByAddingComponents: comps toDate: currentDate options: 0];
[comps release];

self.datePickerView.minimumDate = minDate;
self.datePickerView.maximumDate = maxDate;

NSLog(@"minDate   %@", minDate);
NSLog(@"maxDate%@", maxDate);
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios

6
推荐指数
1
解决办法
5286
查看次数

标签 统计

ios ×1

iphone ×1

xcode ×1