UIDatePicker不显示当天。我该如何更新?

时间:2011-11-01 13:37:18

标签: ios uidatepicker

在IB中,我定于11月28日。当我运行iphone时,显示11月28日。请看截图。

enter image description here

但现在我想显示当天。我该怎么办?

3 个答案:

答案 0 :(得分:1)

datePicker.date = [NSDate date];

答案 1 :(得分:1)

使用NSDate类将选择器设置为日期。

NSDate *date = [NSDate date]; // current day
[picker setDate:date animated:YES];

答案 2 :(得分:0)

//以这种方式设置选择器的日期和时间

NSDate *date = [lodatapicker date];
[dateFormater setDateFormat:@"EEE, MMMM dd yyyy"];
NSString *dateString = [dateFormater stringFromDate:date];
[label setText:dateString]
相关问题