zoukankan      html  css  js  c++  java
  • 获取和设置 iphone 屏幕亮度

    link address:http://hi.baidu.com/myguru/item/c8d5878ca5464cc9b17154e7

    首先,Apple是不允许应用程序这样做的。当然,所谓的不允许,是你提交的应用会被reject。我们如果不提交给AppStore,苹 果当然就管不着了,呵呵。

      实现方法来自于iPhone Dev SDK Forum:

      读取屏幕亮度:

      NSNumber *bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR("SBBacklightLevel" ), CFSTR("com.apple.springboard"));

      previousBacklightLevel = [bl floatValue]; //a variable to store the previous level so you can reset it.

      [bl release]

      设置屏幕亮度:

      GSEventSetBacklightLevel(newLevel); //The new level: 0.0 - 1.0.

      后续的问题:

      1.据说读取屏幕亮度的方法只在2.x的firmware有效,因为今天apple mini没在手里,暂时无法验证。

      2.使用上述功能前,需要进入GraphicsServices.h。

      3.因为是私有API,GSEventSetBacklightLevel(float value)这个方法,可能需要自己额外在GraphicsServices.h里定义一下(有待验证),或者使用ToolChain编译。

      4.一般,会涉及到调节屏幕亮度的程序,都会搭配防止休眠的功能,代码很简单:

      [[UIApplication sharedApplication] setIdleTimerDisabled:YES];

  • 相关阅读:
    CodeForces 706C Hard problem
    CodeForces 706A Beru-taxi
    CodeForces 706B Interesting drink
    CodeForces 706E Working routine
    CodeForces 706D Vasiliy's Multiset
    CodeForces 703B Mishka and trip
    CodeForces 703C Chris and Road
    POJ 1835 宇航员
    HDU 4907 Task schedule
    HDU 4911 Inversion
  • 原文地址:https://www.cnblogs.com/xingchen/p/2922894.html
Copyright © 2011-2022 走看看