需要计数定时器,iPhone编程 [英] Count-Up Timer Required, iPhone Programming
问题描述
我是新的iPhone编程,所以希望有人可以帮助我在这里。我已经搜索网络,但只能找到倒计时器的信息。
I am new to iPhone programming so am hoping someone can help me out here. I have searched the web, but can only find information on count down timers.
我想要做的是,当按下按钮时启动计数器,然后当某个值下降,例如5时,停止它,最后显示该时间。我可以在屏幕上显示值,一旦我有他们,但得到的时间在第一个地方是证明对我很难。
What I am looking to do is start a count up timer when a button is pressed and then stop it when a certain value drops by, say 5, and finally display that time. I can display values on screen once I have them, but getting the time in the first place is proving difficult for me.
如果这是一个简单的问题,我期待着阅读您的回复。
I apologize if this is a simple question, but I look forward to reading your responses.
提前感谢,
stu
Thanks in advance, stu
推荐答案
NSDate
将提供当前日期。您可以使用 - (NSTimeInterval)timeIntervalSinceNow
来获取自第一次调用以来的时间。
NSDate
will provide the current date. You can use - (NSTimeInterval)timeIntervalSinceNow
to get the time since the first call and now.
这篇关于需要计数定时器,iPhone编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!