ios - 应用程序在设置 IdleTimerDisabled : NO 时直接进入空闲状态

标签 ios idle-timer

我正在使用

[[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/

相关文章:

jsf - 通过 PrimeFaces 超时 p :idleMonitor

ios - 如何在iOS中更改空闲计时器延迟时间

ios - 在核心图形中传递 CGFloat 数组

iOS:无法在 didFinishLaunchingWithOptions 中将 UIApplicationidleTimerDisabled 设置为 YES

ios - 有什么好方法可以知道 CLLocationManager 的 startMonitoringForRegion 何时完成?

objective-c - 如何为不同的单元格设置不同的颜色

linux - 本地用户的远程 Linux 空闲时间

ios - 在 SwiftUI 中动画完成后隐藏和显示 View

ios - 对 uitableviewcell 内的 View 进行动画处理