jMelnik jMelnik - 1 year ago 154
iOS Question

How to disable iPhone/iPad auto-lock while app is in foreground mode?

I'm developing an music/video player app and just need to konw how to disable the auto-lock while my app is in foreground.

I know I've to use

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
at some point, but where is the best place to put them?

Answer Source

Enable the idle timer in

- (void)applicationWillResignActive:(UIApplication *)application

and disable it in

- (void)applicationDidBecomeActive:(UIApplication *)application
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download