iPhone:NSTimer 倒计时(显示分钟:秒)
我已经设置了计时器代码,而且一切都正常,但我希望我的标签显示“分钟:秒”而不是仅显示秒。
-(void)countDown{
time -= 1;
theTimer.text = [NSString stringWithFormat:@"%i", time];
if(time == 0)
{
[countDownTimer invalidate];
}
}
我已经将“时间”设置为 600,即 10 分钟。但是,我希望显示屏显示 10:59、10:58 等,直到达到零。
我该怎么做?
谢谢!
I have my timer code set up, and it's all kosher, but I want my label to display "Minutes : seconds" instead of just seconds.
-(void)countDown{
time -= 1;
theTimer.text = [NSString stringWithFormat:@"%i", time];
if(time == 0)
{
[countDownTimer invalidate];
}
}
I've already set "time" to 600, or 10 minutes. However, I want the display to show 10:59, 10:58, etc. until it reaches zero.
How do I do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
到那时,我对第一个答案进行了一些升级,它消除了与 NSInteger 和 int 相关的冲突:
By the time, I was made a little upgrade of first answer, it removed conflicts that associated from
NSInteger
andint
: