简体   繁体   中英

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:

[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. Also, most of the advice is from iOS 3.0.

Is anybody using this in iOS 5, and what are the caveats with its use? 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?


* A lot of info out here: https://stackoverflow.com/search?q=auto-lock+ios

Set it in applicationDidBecomeActive: and unset it in applicationWillResignActive: and you should have no problems.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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