views:

54

answers:

3

Is there a way to prevent the iPad from sleeping while my app runs? I am making a kiosk app that needs to not auto sleep.

+2  A: 

You want the UIApplication.idleTimerDisabled property.

Kevin Ballard
Thanks, see my comment to `igul222`s answer.
Moshe
It only affects the iPad while your app is running.
Kevin Ballard
+2  A: 
[[UIApplication sharedApplication] setIdleTimerDisabled:YES]
igul222
Does this only affect the iPad when my app is running? Do I need to change this back on application exit?
Moshe
Regarding this issue, there is NOTHING you have to do when you exit. Simple!
Joe Blow
A: 

Here's how to do it, as of 2010.

You will have a file called "AppDelegate_Pad.h"...

-(BOOL)application:(UIApplication *)application
            didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
        [window addSubview:yourHappyPlace.view];
        [window makeKeyAndVisible];
        application.idleTimerDisabled = YES;
        return YES;
        }
Joe Blow
Why `as of 2010`?
Moshe
Hi Moshe, things change from time to time. For someone reading this in the future, 2013 or 2020 or 2011, it may be all different. For now the most normal way is to use the property as shown in the code. Hoep it helps!
Joe Blow