简体   繁体   English

iOS中的空闲计时器

[英]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. 在“设置”中,我将锁定时间设置为30秒。 After some time the screen goes blank, and the device does not respond to touches and Home button pressing. 一段时间后,屏幕变为空白,并且设备对触摸和按下Home按钮不响应。 Checked on iOS 9.2 (13C75), iPhone 5 ans 5s. 在iOS 9.2(13C75),iPhone 5和5s上进行检查。

The same problem was occuring with me. 我也发生了同样的问题。 Actually it does work but only works when your device is not connected to xCode. 实际上,它确实有效,但仅在您的设备未连接到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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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