更改背光级别,iPhone [英] Changing Backlight Level, iPhone

查看:71
本文介绍了更改背光级别,iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处寻找一种在iPhone上的应用程序中设置背光亮度的方法.我在这里找到了解决方案:

I searched around for a way to set the backlight level within an app on the iPhone. I found a solution here:

http://www.iphonedevsdk.com/forum/29097-post3.html

我遇到的问题是,当我将其添加到我的应用程序时,出现错误和警告.我的代码如下:

The problem I have is, when I add this to my app I get an error and a warning. My code is as follows:

#include "GraphicsServices.h"

- (void) viewWillAppear:(BOOL)animated
{

NSNumber *bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR("SBBacklightLevel" ), CFSTR("com.apple.springboard"));
previousBacklightLevel = [bl floatValue];
//Error here : incompatible types in assignment

[bl release];   

GSEventSetBacklightLevel(0.5f);
// Warning here : implicit declaration of function 'GSEventSetBacklightLevel'

}

//...The rest of my app

- (void)applicationWillTerminate:(UIApplication *)TheNameOfMyAppIsHere
{
    GSEventSetBacklightLevel(previousBacklightLevel);
}

我不确定是什么原因造成的.我也真的不知道在我的.h文件中需要包含什么,但是我有:

I am unsure of what is causing this. I also don't really know what needs to be in my .h file here, but I have:

NSNumber *previousBacklightLevel;

编辑//已更改

NSNumber *previousBacklightLevel 

float previousBacklightLevel;

根据建议,这将分配错误中的不兼容类型排序.

as suggested and this sorted the incompatible types in assignment error.

现在剩下:

"_ GSEventSetBacklightLevel",引用自:

"_GSEventSetBacklightLevel", referenced from:

-MyAppViewController.o中的[MyAppViewController viewWillAppear:]

-[MyAppViewController viewWillAppear:] in MyAppViewController.o

-MyAppViewController.o中的[MyAppViewController applicationWillTerminate]

-[MyAppViewController applicationWillTerminate] in MyAppViewController.o

未找到符号

collect2:ld返回1个退出状态

collect2: ld returned 1 exit status

也不知道该如何解决!

任何帮助,我们都会感激的,

Any help would be appreciated,

//编辑

所有问题已排序.感谢所有帮助我的人.我真的很感激,并且迫不及待地想通过回答一些问题给我一点回报.

All problems sorted. Thanks to all who helped me out. I really do appreciate it and can't wait till I can give a little back, by answering some questions.

非常感谢,

斯图

推荐答案

收到警告的原因是,GSEventSetBacklightLevel()是未在任何SDK标头中声明的私有API.如果您打算将其提交给应用商店,则调用该应用将被拒绝.如果这是用于越狱的设备,则可以自行声明该功能.

The reason you are getting a warning is because GSEventSetBacklightLevel() is a private API not declared in any of of the SDK headers. If you are planning to submit this to the app store your app will get rejected if you call it. If this is for a jailbroken device, you can just declare the function yourself.

void GSEventSetBacklightLevel(float level);

出现错误的原因是因为您试图将浮点数(标量)分配给NSNumber *.您可能希望将previousBacklightLevel更改为float.

The reason you are getting the error is because you are trying to assign a float (which is a scalar) to an NSNumber *. You probably want to change previousBacklightLevel to be a float.

这篇关于更改背光级别,iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆