| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

NSDatePicker的使用(设置日期范围)

设置日期期限的时候下面这个方法用不了(升级成ios7之后)

 NSDate *toDate =[[NSDate alloc]initWithString:@"2000-10-10 12:00:00 -0500"];

用下面的方法替换

    NSDateFormatter * formatter = [[NSDateFormatter alloc]init];        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];        NSString * mindateStr = @"1900-01-01 00:00:00";        NSString * maxdateStr = @"2099-01-01 00:00:00";        NSDate * mindate = [formatter dateFromString:mindateStr];        NSDate * maxdate = [formatter dateFromString:maxdateStr];        datepiker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 40, 320, 180)];        datepiker.datePickerMode = UIDatePickerModeDate;//设置日期显示格式        datepiker.minimumDate = mindate;        datepiker.maximumDate = maxdate;        datepiker.backgroundColor = [UIColor  whiteColor];