jMelnik jMelnik - 7 months ago 40
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?


Enable the idle timer in

- (void)applicationWillResignActive:(UIApplication *)application

and disable it in

- (void)applicationDidBecomeActive:(UIApplication *)application