我正在使用
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
防止应用程序进入空闲状态,但是当我发出时
[[UIApplication sharedApplication] setIdleTimerDisabled: NO];
应用程序直接进入空闲状态。
此时有没有办法重新启动定时器?
最佳答案
不,没有办法重新启动计时器。也许您应该考虑您的应用程序是否真的需要这样做。 来自 Apple 的引述:
"The only applications that should disable the idle timer are mapping applications, games, or similar programs with sporadic user interaction."
如果您的应用确实需要关闭 idleTimer,那么也许它可以一直关闭直到应用进入后台?
您可以尝试在定时事件结束时添加提醒
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"Timer Complete" message:@"Timer ended, well don you" delegate:nil cancelButtonTitle:@"OKAY" otherButtonTitles:nil];
[myAlert show];
[myAlert release];
如果您使用的是 ARC,请省略发布。这可能会点亮屏幕备份,然后也许您不需要弄乱空闲计时器。
关于ios - 应用程序在设置 IdleTimerDisabled : NO 时直接进入空闲状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11796914/