Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-17-2011, 05:27 AM   #20 (permalink)
Winmax
Registered Member
 
Join Date: Feb 2011
Posts: 2
Winmax is on a distinguished road
Default

Quote:
Originally Posted by chenxintao View Post
Hi,I want to use GSEventSetBacklightLevel, and I have #import "GraphicsServices.h", but there is a error. "_GSEventSetBacklightLevel", referenced from: .... symsbol not found.
And I can't find GraphicsServices.framework.How can I do to use GSEventSetBacklightLevel ?
Hi,
i Managed to get it working, maybe you/someday some else can find your/his solution with my code snip.

I used to change the backlight level with a UISlider, and programmatically with some "pulse" effect.

some vars needed in my code
Code:
	// init global vars
	_currentBacklightLevel = 0.2f;
	[self setBacklightLevel:_currentBacklightLevel];
	_pulseBacklightDirection = 0; // 0 = off, 1 = up, 2 = down

Creating my slider
Code:
	// create brightnessSlider
	brightnessSlider = [[UISlider alloc] initWithFrame:CGRectMake(18.0f, 420.0f, 258.0f, 23.0f)];
	[brightnessSlider addTarget:self action:@selector(brightnessSliderChanged:) forControlEvents:UIControlEventValueChanged];
	[brightnessSlider setBackgroundColor:[UIColor clearColor]];
	brightnessSlider.minimumValue = 0.0;
	brightnessSlider.maximumValue = 1.0;
	brightnessSlider.continuous = YES;
	brightnessSlider.value = _currentBacklightLevel;
	[self.view addSubview:brightnessSlider];

The main method, remember you won't pass appstore policy with this.
Code:
- (void)setBacklightLevel: (float)newLevel {
[(id)[UIApplication sharedApplication] setBacklightLevel:newLevel]; // newLevel between 0.0f and 1.0f
}


My pulse function, just some little play i made
Code:
- (void)pulseBacklight {
		
	
	if (_pulseBacklightDirection > 0) {		
		if (_pulseBacklightDirection == 1) {
			if (_currentBacklightLevel < 0.975f) _currentBacklightLevel += 0.025f;
			else _pulseBacklightDirection = 2;
			
		}
		else if (_pulseBacklightDirection == 2) {
			if (_currentBacklightLevel > 0) _currentBacklightLevel -= 0.025f;
			else _pulseBacklightDirection = 1;
		}
		[self setBacklightLevel: _currentBacklightLevel];
		brightnessSlider.value = _currentBacklightLevel;
		[self performSelector:@selector(pulseBacklight) withObject:nil afterDelay:0.01f];
	}
	else {
		[self setBacklightLevel:0.5f];
		_currentBacklightLevel = 0.5f;
	}


}
Hope someday someone will see this, smile, and get his work done

Greetings
Max
Winmax is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,597
Threads: 94,084
Posts: 402,781
Top Poster: BrianSlick (7,990)
Welcome to our newest member, aaronredmond844
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:41 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.