How can I keep the iPhone from sleeping?
Turn off all sleep schedules and alarmsTap Browse at the bottom right, then tap Sleep. Scroll down to Your Schedule. Tap Full Schedule & Options, then turn off Sleep Schedule (at the top of the screen). You can turn them all on again later.
The reason your iPhone's screen keeps dimming and turning off is because of a feature called “Auto-Lock,” which automatically puts the iPhone into a sleep/lock mode after a certain period of time. Two-thirds of the way through the set period, the screen dims to half brightness.
To stop your app from timing out and going to sleep you can use:
[UIApplication sharedApplication].idleTimerDisabled = YES;
This will, obviously, disable the idle timer and stop your iphone from automatically going into sleep mode.
Edit: As middaparka stated you should re-enable the idle timer when you no longer need to keep the phone awake (generally after that view has been removed) using:
[UIApplication sharedApplication].idleTimerDisabled = NO;
Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With