Created
August 20, 2014 05:25
-
-
Save adison/9a93aa7b0935befd46e0 to your computer and use it in GitHub Desktop.
flash light test snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // from http://stackoverflow.com/questions/11726543/how-to-turn-flashlight-on-off-using-one-button | |
| AVCaptureDevice *flashLight = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; | |
| if ([flashLight isTorchAvailable] && [flashLight isTorchModeSupported:AVCaptureTorchModeOn]) | |
| { | |
| BOOL success = [flashLight lockForConfiguration:nil]; | |
| if (success) | |
| { | |
| if ([flashLight isTorchActive]) { | |
| [flashLight setTorchMode:AVCaptureTorchModeOff]; | |
| } else { | |
| [flashLight setTorchMode:AVCaptureTorchModeOn]; | |
| } | |
| [flashLight unlockForConfiguration]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment