【发布时间】:2013-08-30 22:42:44
【问题描述】:
我有一个 UIDatePicker 和一个 UILabel 来显示所选日期。现在,日期显示为“2013-8-30 10:30:54 +0000”。我希望日期改为按“dd:hh:mm:ss”的顺序显示为“00:00:00:00”。然后我想从 IBAction 启动一个计时器,该计时器从显示中的“dd:hh:mm:ss”中选择的日期开始倒计时。我可以分析的任何帮助或参考代码将不胜感激。我是新手,完全是自学的。提前致谢。干杯!
@synthesize picker;
@synthesize label;
-(IBAction)displayDate:(id)sender {
NSDate *selected = [picker date];
NSString *date = [selected description];
self.label.text = date;
}
- (void)viewDidLoad {
NSDate *now = [NSDate date];
[picker setDate:now animated:YES];
self.label.text = [now description];
}
@end
【问题讨论】:
-
使用
NSDateFormatter以所需格式显示NSDate。现有的例子不胜枚举。
标签: ios nstimer uidatepicker countdown