问题描述
我目前有一个非常简单的应用程序,唯一的互动是摇动iPhone。然而,最终屏幕变暗和自动锁定,因为iPhone没有任何触摸事件。我想知道是否有办法在动摇时重置自动锁定超时?
I currently have a very simple app for which the only interaction is shaking the iPhone. However eventually the screen dims and auto-locks since the iPhone is not getting any touch events. I was wondering if there is a way to reset the auto-lock time-out when shaken?
我知道要完全禁用自动锁定我会这样做:
I know that to disable auto-lock completely I would do this:
[[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ]
但我真的不想完全禁用它;如果合法地不使用iPhone,它应该按预期自动锁定。
but I don't really want to disable it completely; if the iPhone is legitimately not being used it should auto-lock as expected.
感谢您的帮助。
推荐答案
您可以根据您自己的NSTimer或行为手势的值来切换 [UIApplication sharedApplication] .idleTimerDisabled
的值(摇动电话)。它可以在您的应用程序中多次设置为 YES
/ NO
。
You could toggle the value of [UIApplication sharedApplication].idleTimerDisabled
based on the value of your own NSTimer or behavioral gesture (shaking the phone). It can be set to YES
/NO
multiple times in your application.
这篇关于延迟但不禁用iPhone自动锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!