How to Prevent iPhone from Sleeping

The automatic sleep timer is one of the ways the iPhone saves power. If the screen isn’t touched for a certain amount of time, it dims the screen and eventually turns it off. Although you should leave the timer on, there are times when this is not what you want (games are a good example).

To disable the timer, set the idleTimerDisabled property to YES, like so …

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];