Keep iPhone from sleeping [duplicate]

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)