【发布时间】:2013-02-26 13:23:03
【问题描述】:
在我的应用程序中,我让用户使用 UIDatePicker's CountDownTimer 设置倒数计时器。
我有一个UILabel 来显示计数时间当用户从 CountDownTimer 中选择时间时,我想显示在 CoutDownTimer 中选择的用户倒计时,如下图所示。
所以我使用以下代码检索用户从CountDownTimer 中选择的计数时间
self.dateFormatter = [[NSDateFormatter alloc] init];
[self.dateFormatter setDateFormat:@"HH:mm:ss"];
self.sleepTimer = [NSTimer timerWithTimeInterval:1.00 target:self selector:@selector(timerFired:) userInfo:nil repeats:NO];
当它到达 00:00 时,我想触发一个事件。
我不知道如何减少每一秒的倒计时。
感谢您的帮助。
【问题讨论】:
-
是的,我知道,但我不知道如何每秒减少 1 个
-
你需要一个变量在每次定时器触发时递减,直到它达到 0。
-
兄弟,我该怎么做?请提供代码
-
datePicker.countDownDuration -= 1;
标签: ios cocoa-touch uidatepicker