2012-12-21 74 views
0

enter image description here我做了一個時間選擇器的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]; 

回答

0

我不知道這是否解決您的問題,但不是

datePicker.minimumDate = [gregorian dateFromComponents:comps];

應該有

datePicker.date = [gregorian dateFromComponents:comps];

相關問題