gpt4 book ai didi

ios - 如何在 iOS 上使用 swift 防止应用程序屏幕锁定

转载 作者:行者123 更新时间:2023-11-30 10:25:38 24 4
gpt4 key购买 nike

如何防止仅在使用导航时屏幕锁定?

Waze 可以选择执行此操作,我如何在我的应用程序中执行此操作?

最佳答案

使用这个:

Objective-C:

[[UIApplication sharedApplication] setIdleTimerDisabled: YES];

Swift(旧版):

UIApplication.sharedApplication().idleTimerDisabled = true

Swift 3 及以上版本:

UIApplication.shared.isIdleTimerDisabled = true

确保导入 UIKit

Here是来自developer.apple.com 的文档链接。

关于ios - 如何在 iOS 上使用 swift 防止应用程序屏幕锁定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60071380/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com