试图实现
停止屏幕在某些时候进入睡眠状态View Controller
我所做
的我已经在运行 iOS 12.1.12 的物理 iPhone 6 上使用以下代码测试了我的应用程序。我将手机设置Dislpay & Brigthness > Auto-Lock为 30 秒。我运行该应用程序并在特定的 VC 上运行UIApplication.shared.isIdleTimerDisabled = true,即使在 30 秒后屏幕仍然亮着。当我切换到其他没有 的 VC 时UIApplication.shared.isIdleTimerDisabled = true,屏幕将在 30 秒后关闭。
我分发到 AppStore 并且我确信我已经上传了正确的版本并从 AppStore 下载了一个新副本,屏幕总是亮着的东西根本不起作用,屏幕总是会在Auto-Lock设置后关闭。
我已经阅读了一些文章https://docs.kioskproapp.com/article/899-ios-12-with-guided-access-causing-kiosk-pro-to-sleep和isIdleTimerDisabled 在 iOS 12 中不起作用
我尝试了Guided Access并打开了Guided Access和Mirror Display Auto-Lock > ON。它仍然不适用于 AppStore 中的应用程序。请帮忙。
代码
override func viewDidLoad() {
super.viewDidLoad()
//==== For the screen to remains on
UIApplication.shared.isIdleTimerDisabled = true
}
override func viewDidDisappear(_ animated: Bool) {
//=== Switch off the screen always on, back to the phone settings.
UIApplication.shared.isIdleTimerDisabled = false
}