0

在此处输入图像描述我将 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];
4

1 回答 1

0

我不确定这是否能解决您的问题,但不是

datePicker.minimumDate = [gregorian dateFromComponents:comps];

应该有

datePicker.date = [gregorian dateFromComponents:comps];

于 2013-04-24T11:46:05.730 回答