用UIApplication的idleTimerDisabled属性控制是否锁屏

来源:互联网 发布:win10打不开网络设置 编辑:程序博客网 时间:2024/05/16 11:47

idleTimerDisabled

A Boolean value that controls whether the idle timer is disabled for the application.

@property(nonatomic, getter=isIdleTimerDisabled) BOOL idleTimerDisabled
Discussion

The default value of this property is NO. When most applications have no touches as user input for a short period, the system puts the device into a "sleep” state where the screen dims. This is done for the purposes of conserving power. However, applications that don't have user input except for the accelerometer—games, for instance—can, by setting this property to YES, disable the “idle timer” to avert system sleep.

Important: You should set this property only if necessary and should be sure to reset it to NO when the need no longer exists. Most applications should let the system turn off the screen when the idle timer elapses. This includes audio applications. With appropriate use of Audio Session Services, playback and recording proceed uninterrupted when the screen turns off. The only applications that should disable the idle timer are mapping applications, games, or similar programs with sporadic user interaction.