NSTimer在iPhone关闭应用程序后继续计数 [英] NSTimer Keep counting after app is closed in iPhone
本文介绍了NSTimer在iPhone关闭应用程序后继续计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个计时器必须计算最多8小时(28800秒)
之后应该发布
I have a timer that have to count up to 8 hours (28800 second) after that it should be released
我想知道如何保持计时器在后台运行和/或应用程序关闭时?
im wondering how to keep the timer running at the background and/or when application is closed?
这是NSTimer:
stopWatchTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateTimer)
userInfo:nil
repeats:YES];
这是我的条件:
counter++;
if (counter >= 28800) {
[stopWatchTimer invalidate];
counter =0;
timeLabel.text = @"Time Out";
}
推荐答案
你不能 - 一次你的应用程序已关闭,然后它不再运行,因此计时器也不会运行。
You can't - once your app is closed then it's not running anymore so the timer won't be running either.
看看本地通知?
这篇关于NSTimer在iPhone关闭应用程序后继续计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文