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

1.8k views Asked by At

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

1

There are 1 answers

4
idz On BEST ANSWER

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 (e.g. 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.