户重置为applicationDidEnterBackgroun

户重置为applicationDidEnterBackgroun

本文介绍了快速将用户重置为applicationDidEnterBackground中的默认应用亮度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用以下代码在应用程序委托方法applicationDidEnterBackground中重置用户的默认设备亮度:

I've been trying to reset the user's default device brightness in the app delegate method: applicationDidEnterBackground by using this code:

UIScreen.mainScreen().brightness = screenBrightness!

该代码被调用,但亮度未重置.任何人都知道如何使用Swift(而不是obj-c)来实现此目的

The code gets called but the brightness is not reset. Anyone know how to get this working using Swift (not obj-c)

推荐答案

此代码看起来正确,但请注意,它将在模拟器中不起作用,仅在物理设备上生效.

This code looks correct, but note that it will not work in the simulator, it will only take effect on a physical device.

此外,请确保screenBrightness的值介于0和1之间.

Also, ensure that the value of screenBrightness is between 0 and 1.

在后台时,您可能将无法更改屏幕亮度.从Apple的文档中:

You will likely not be able to change the screen brightness while in the background. From Apple's documentation:

这篇关于快速将用户重置为applicationDidEnterBackground中的默认应用亮度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:38