iPhone brightness private API not working properly

╄→гoц情女王★ 提交于 2019-12-31 01:53:08

问题


I am trying to set the brightness of the backlight, but it's acting very strangely. I am using the private API:

[(id)[UIApplication sharedApplication] setBacklightLevel:1.0f];

However, when I call this, the screen dims, not becoming 100% bright like I thought it would. I have tested this with a variety of numbers, and here is what I got:

0.2: dark

0.3: light

0.4: dark

0.5: dark

0.6: light

0.7: dark

0.8: dark

0.9: dark

1.0: dark

1.1: dark

1.2: light

1.3: dark

1.4: dark

1.5: light

Some of the values were slightly brighter than the darkest values, but that is the overall trend. It doesn't seem like the pattern makes any sense. Does anyone know what scale the brightness should be on?


回答1:


The problem is that the compiler doesn't know a method takes a float unless you declare it. So the float you pass in is getting converted to another type when you pass it and then that new bit pattern being reinterpreted as a float by the method. You just need to have the method declared in a header that file knows about and the float will be passed unaltered.



来源:https://stackoverflow.com/questions/4740261/iphone-brightness-private-api-not-working-properly

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