iOS-setIdleTimerDisabled:NO不起作用 [英] iOS - setIdleTimerDisabled:NO Not Working
问题描述
我有一个利用摄像机的应用程序,因此屏幕不会变暗.禁止屏幕变暗就像这样:
I have an app that utilizes the video camera so the screen cannot dim. Inhibiting the screen from dimming works fine like so:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
}
但是,当应用程序关闭并进入后台时,将IdleTimer设置回NO无效.屏幕永远停留在主屏幕上.这就是我试图达到的目的.
However when the app is closed and enters the background, setting the IdleTimer back to NO is not working. The screen stays on forever on the home screen. This is how I am trying to accomplish this.
- (void)applicationWillResignActive:(UIApplication *)application
{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
}
有没有更好的地方添加这一行代码?
Is there a better place to add this line of code?
推荐答案
我也发生了同样的问题.实际上,它确实有效,但仅在您的设备未连接到xCode时才有效.尝试断开设备的连接,然后测试此功能.
The same problem was occuring with me. Actually it does work but only works when your device is not connected to xCode. Try disconnecting the device and then test this functionality.
这篇关于iOS-setIdleTimerDisabled:NO不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!