延迟但不禁用 iPhone 自动锁定 [英] Delaying but not disabling iPhone auto-lock

查看:36
本文介绍了延迟但不禁用 iPhone 自动锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个非常简单的应用程序,唯一的交互就是摇动 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 或行为手势(摇动电话).它可以在您的应用程序中多次设置为 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 自动锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆