Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
AVFlashlight: Difference between revisions - iPhone Development Wiki

AVFlashlight: Difference between revisions

From iPhone Development Wiki
m (Example usage.)
(formatting and navbox)
Line 1: Line 1:
[[AVFlashlight]] is a private class introduced in iOS 7 for turning the device's LED flash on or off. The example application that use this class is Control Center in [[SpringBoard]].
[[AVFlashlight]] is a private class introduced in iOS 7 for turning the device's LED flash on or off. The example application that uses this class is Control Center in [[SpringBoard]].


== Methods ==
== Methods ==
Line 17: Line 17:
The method {{ObjcCall|AVFlashlight|setFlashlightLevel:withError:}} is used for setting the flashlight level.
The method {{ObjcCall|AVFlashlight|setFlashlightLevel:withError:}} is used for setting the flashlight level.


Example usage:
== Example usage ==
 
<source lang=objc>
<source lang=objc>
AVFlashlight *flashlight;
AVFlashlight *flashlight;
Line 32: Line 33:
[flashlight release];
[flashlight release];
</source>
</source>
{{occlass|library=AVFoundation.framework|navbox=1}}

Revision as of 20:18, 18 February 2014

AVFlashlight is a private class introduced in iOS 7 for turning the device's LED flash on or off. The example application that uses this class is Control Center in SpringBoard.

Methods

Signature +(BOOL)hasFlashlight;
Available in 7.0 —

The method +[AVFlashlight hasFlashlight] indicates the LED flash availability.

Signature -(BOOL)setFlashlightLevel:(float)level withError:(NSError *)error;
Available in 7.0 —

The method -[AVFlashlight setFlashlightLevel:withError:] is used for setting the flashlight level.

Example usage

AVFlashlight *flashlight;

...

// Make sure you don't have any others AVFlashlight object instantiated
flashlight = [[AVFlashlight alloc] init];
[flashlight setFlashlightLevel:AVCaptureMaxAvailableTorchLevel withError:nil];

...

// Do this when you want to turn power/light off the LED flash
[flashlight release];