idleTimerDisabled not working since iPhone 3.0

前端 未结 5 1792
無奈伤痛
無奈伤痛 2020-12-02 21:09

I have used:

[UIApplication sharedApplication].idleTimerDisabled = YES;

in a number of Apps developed and running under iPhone OS 2.x and n

5条回答
  •  再見小時候
    2020-12-02 21:54

    Even in 2015, using iOS 8.2, this bug is still alive and kicking.

    Here's my solution, using XCode 6.2.

    iPhone - phone goes to sleep even if idleTimerDisabled is YES

    Basically, even now, in 2015, the only way to safely make sure that the device doesn't go to sleep is to repeatedly call a piece of code to keep the device awake.

    -(void)callEveryTwentySeconds
    {
        //  DON'T let the device go to sleep during our sync
        [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
        [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    }
    

提交回复
热议问题