设备自动锁定

发布于 2024-10-28 07:47:28 字数 240 浏览 0 评论 0原文

我有一个应用程序,我想在其中以编程方式锁定 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光沙漏 2024-11-04 07:47:28

仅通过编程方式锁定 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

橘亓 2024-11-04 07:47:28

无法使用记录的 API 来禁用 iOS 中的主页按钮。用户始终可以使用“主页”按钮返回主屏幕或关闭应用程序。

即使您找到了一种方法(这不太可能),您的应用程序也肯定会因公然违反 iOS 人机界面指南。如果我是你,我会重新考虑实施这种行为,坦率地说,这不是一个好主意。

如果您只想阻止应用程序的 UI,查看此问题的答案,更具体地说,查看非常有用的MBProgressHUD 库:

MBProgressHUD
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:

MBProgressHUD
MBProgressHUD

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文