简体   繁体   中英

Idle timer in iOS

I use this code

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

for autolock disabling. In Settings I set the lock time of 30 seconds. After some time the screen goes blank, and the device does not respond to touches and Home button pressing. Checked on iOS 9.2 (13C75), iPhone 5 ans 5s.

The same problem was occuring with me. Actually it does work but only works when your device is not connected to xCode. Try disconnecting the device and then test this functionality.

Try this funny hack.

[UIApplication sharedApplication].idleTimerDisabled = NO;
[UIApplication sharedApplication].idleTimerDisabled = YES;

instead of

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM