设备自动锁定
我有一个应用程序,我想在其中以编程方式锁定 iPhone,以便用户无法执行任何操作。
如何确定用户在一段时间内没有使用 iPhone,并在该时间段之后自动锁定手机?
此类应用程序用于所有电话设备,用户可以设置自动锁定时间,然后如果用户不操作设备,设备将自动锁定。 它是如何以编程方式完成的?请给我一个代码示例,以便我可以轻松地执行此操作。
我是 iPhone 编程新手,我在我的应用程序中遇到了困难。帮我。提前致谢。
I have an application in which I want to lock the iPhone programmatically so that the user can't perform any action.
How can I determine the user is not working with the iPhone for some period, and after that period automatically lock the phone?
Such applications are used in all phone devices, where the user can set an auto-lock time and then the device will automatically lock if the user does not handle the device.
How is it done programmatically? Please give me one example of the code so I can perform this easily.
I am new to iPhone programming, and I am struggling in my application. Help me. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(仅通过编程方式锁定 iPhone 设备)
不可能。
但是,您可以在应用程序运行时阻止手机锁定。
[UIApplication共享应用程序].idleTimerDisabled = YES
(For your lock the iphone device through programatic only )
Impossible.
But , you could prevent your phone from locking when your app is running.
[UIApplication sharedApplication].idleTimerDisabled = YES
无法使用记录的 API 来禁用 iOS 中的主页按钮。用户始终可以使用“主页”按钮返回主屏幕或关闭应用程序。
即使您找到了一种方法(这不太可能),您的应用程序也肯定会因公然违反 iOS 人机界面指南。如果我是你,我会重新考虑实施这种行为,坦率地说,这不是一个好主意。
如果您只想阻止应用程序的 UI,查看此问题的答案,更具体地说,查看非常有用的MBProgressHUD 库:
There is no way to disable the Home Button in iOS using the documented API. The user will always be able to get back to the home screen or close your application using the Home Button.
Even if you find a way do it (which is very unlikely) your app will be definitely rejected from the App Store for a blatant violation of the iOS Human Interface Guidelines. If I were you I would reconsider implementing this behaviour, frankly, it's just not a good idea.
If you're only looking for blocking the the UI of your app, check out the answers to this question, more specifically, check out the incredibly useful MBProgressHUD library: