如何在IOS上使用swift防止我的应用程序上的屏幕锁定 [英] How to prevent screen lock on my application with swift on IOS
本文介绍了如何在IOS上使用swift防止我的应用程序上的屏幕锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何仅在使用导航时阻止屏幕锁定。 Waze可以选择这样做,我怎么能在我的应用程序中执行此操作?
How can I prevent screen lock only when using Navigation. Waze has the option to do that, how can I do this in my App?
推荐答案
使用此:
Objective-C:
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
Swift(传统):
UIApplication.sharedApplication().idleTimerDisabled = true
Swift 3/4:
UIApplication.shared.isIdleTimerDisabled = true
确保导入 UIKit
。
这里是指向来自apple.developer.com的文档。
Here is the link to the documentation from apple.developer.com.
这篇关于如何在IOS上使用swift防止我的应用程序上的屏幕锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文