在应用程序运行时如何防止iPhone屏幕变暗或关闭? [英] How do I prevent the iPhone screen from dimming or turning off while my application is running?

查看:791
本文介绍了在应用程序运行时如何防止iPhone屏幕变暗或关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款不需要用户输入的应用,但我不希望iPhone进入省电模式。

I'm working on an app that requires no user input, but I don't want the iPhone to enter the power saving mode.

是否可以禁用应用程序的省电功能?

Is it possible to disable power saving from an app?

推荐答案

Objective-C

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

Swift

UIApplication.shared.isIdleTimerDisabled = true

这篇关于在应用程序运行时如何防止iPhone屏幕变暗或关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆