我現在擁有的日期選擇器具有類似於:mm/dd/YYYY的樣式,並在「YYYY/MM/DD」的Textfield中顯示。更改日期選擇器樣式iphone
我該如何更改我的代碼,以便所顯示的日期選擇器也更改爲「YYYY/MM/DD」。 這裏是我的代碼:
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] ;
NSDate *currentDate = [NSDate date];
NSDateComponents *comps = [[NSDateComponents alloc] init] ;
[comps setYear:-10];
NSDate *maximumDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0];
[comps setYear:-10];
NSDate *minimumDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0];
UIDatePicker *datePicker = [[UIDatePicker alloc]init];
datePicker.datePickerMode = UIDatePickerModeDate;
[datePicker setMaximumDate:maximumDate];
[datePicker setMinimumDate:minimumDate];
[datePicker addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.Birthday setInputView:datePicker] ;
這裏是我的語言環境信息: DF = [[NSDateFormatter的alloc]初始化] ; df.locale = [[NSLocale alloc] initWithLocaleIdentifier:@「en_US_POSIX」]; df.dateFormat = @「yyyy-MM/dd'T'HH:mm:ssZZZZZ」; [dictionary setObject:df forKey:kAPIDateFormatter];即使我正在chaning這個tha格式仍然是一樣的! – 2013-02-25 22:19:53