简体   繁体   English

关闭iPad上的自动锁定:最新信息

[英]Shut Off Auto-Lock on iPad: Up-To-Date Information

I have been reading through questions * and answers about how to stop an iOS device from suspending, starting with the most general to more specific questions that discuss problems with this code: 我一直在阅读问题*和关于如何阻止iOS设备暂停的答案,从讨论此代码问题的最一般到更具体的问题开始:

[UIApplication sharedApplication].idleTimerDisabled = YES;

Some suggest turning it to NO before turning it on (sounds bogus but who knows), some suggest that you need to turn it on often (what?), and other such advice. 有人建议在开启之前把它变为NO (听起来很虚伪但是谁知道),有些人建议你需要经常打开它(什么?),以及其他这样的建议。 Also, most of the advice is from iOS 3.0. 此外,大多数建议来自iOS 3.0。

Is anybody using this in iOS 5, and what are the caveats with its use? 是否有人在iOS 5中使用此功能,使用它的注意事项是什么? I do not want the device to suspend (auto-lock) at any time if my app is in the foreground (battery be damned). 如果我的应用程序在前台(电池被诅咒),我不希望设备随时暂停(自动锁定)。 Will idleTimerDisabled do this? idleTimerDisabled会这样做吗?


* A lot of info out here: https://stackoverflow.com/search?q=auto-lock+ios *这里有很多信息: https//stackoverflow.com/search?q = auto-lock+ios

Set it in applicationDidBecomeActive: and unset it in applicationWillResignActive: and you should have no problems. applicationDidBecomeActive:设置它applicationDidBecomeActive:并在applicationDidBecomeActive:取消设置它applicationWillResignActive:你应该没有问题。

Most of the times when people have a problem with it "not working" the user has switched to some other app (eg camera) and they are expecting their setting to magically be restored! 大多数时候,当人们遇到“不工作”的问题时,用户已经切换到其他应用程序(例如相机),他们希望他们的设置能够神奇地恢复!

I have an app in the app store the uses this and have had no complaints of it not working so far. 我在应用程序商店中有一个应用程序,并且没有抱怨它到目前为止无法正常工作。 Depending on your app you may want to give the user the option of turning this on and off. 根据您的应用程序,您可能希望为用户提供打开和关闭此选项的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM