0
我做了一個時間選擇器的UIDatePicker,並將其時間設置爲15:00。在某些地區,如美國,它將在03:00正確顯示,但不是「PM」,而是顯示「AM」。有關如何正確設置它的任何想法?上午/下午設置爲UIDatePicker錯誤
當前代碼:
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];