Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个禁用空闲计时器的应用程序。如何在应用程序崩溃或用户点击主退出按钮之前重新启用它?否则会耗尽电池电量,这可能会非常糟糕。
您可以在- (void)applicationWillResignActive:(UIApplication *)application方法中重新启用它。
- (void)applicationWillResignActive:(UIApplication *)application
你可以使用这个:[[UIApplication sharedApplication] setIdleTimerDisabled:NO]. 当您的应用程序处于活动状态时,不要忘记再次禁用它。
[[UIApplication sharedApplication] setIdleTimerDisabled:NO]