Prevent iPhone to sleep

北慕城南 提交于 2019-12-12 10:10:46

问题


I using accelerometer in my app and i'm using [UIApplication sharedApplication].idleTimerDisabled = YES; to prevent the device to sleep. It works fine, but this way the screen is always on full bright, there is a way to prevent the device to sleep and keep the energy economy mode on? When idleTimerDisabled is stetted to NO the device enter in the energy economy mode before sleep, i just want to prevent the device to sleep and keep the energy economy. There is a way to do that?


回答1:


There's a property of UIScreen instances, brightness, that is likely what you want. Check out the documentation of UIScreen's brightness property here.

Try:

[[UIScreen mainScreen] setBrightness: 0.3];

NOTE: As I was posting, DarkXphenomenon posted a link to an SO question whose asker gave the exact same solution. DarkXphenomenon is quick on the draw.



来源:https://stackoverflow.com/questions/11486036/prevent-iphone-to-sleep

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!