xcode 避免iphone进入睡眠模式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1816825/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Avoid the iphone go into sleep mode
提问by Zeeshan Rang
I have made an iphone fitness application. The issue i am unable to resolve here is that, while the application is running, the iphone goes in the sleep mode, and hence the accelerometer and sound turns off. Which i dont want to happen.
我做了一个iphone健身应用程序。我在这里无法解决的问题是,当应用程序运行时,iphone 进入睡眠模式,因此加速度计和声音关闭。这是我不想发生的。
Is there anyway i can avoid this from happening? If not that, atleast i could increase the time of my iphone to go into sleep mode.
无论如何我可以避免这种情况发生吗?如果不是这样,至少我可以增加我的 iphone 进入睡眠模式的时间。
Regards Zeeshan
问候泽山
回答by epatel
Try this
尝试这个
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
回答by KatokichiSoft
As Jacob and epatel said, the [[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ];
is the way you wanted. However, you'd better to implement when the application is interrupted by other signal. It means that you'd implement - (void)applicationWillResignActive:(UIApplication *)application
method.
正如 Jacob 和 epatel 所说,这[[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ];
就是您想要的方式。但是,您最好在应用程序被其他信号中断时执行。这意味着您将实现- (void)applicationWillResignActive:(UIApplication *)application
方法。
Because, there are enforced interruption on the iPhone/iPod touch. A phone call, push a power button, and so on.
因为,在 iPhone/iPod touch 上有强制中断。一个电话,按一下电源按钮,等等。