我将UIDatePicker设为时间选择器,并将时间设置为15:00。在某些地区,例如美国,它将在车轮中正确显示为03:00,而不是" PM",它显示" AM"。有关如何正确设置的任何想法?
当前代码:
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps = [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:_dateWithTime];
comps.hour = 15;
comps.minute = 0;
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeTime;
datePicker.minuteInterval = 15;
datePicker.timeZone = [NSTimeZone localTimeZone];
datePicker.minimumDate = [gregorian dateFromComponents:comps];
[datePicker addTarget:self action:@selector(checkinDatePickerChanged:) forControlEvents:UIControlEventValueChanged];
答案 0 :(得分:0)
我不确定这是否可以解决您的问题,而不是
datePicker.minimumDate = [gregorian dateFromComponents:comps];
应该有
datePicker.date = [gregorian dateFromComponents:comps];