Added an option for camera flash to be on/off/auto during QR code scanning

This commit is contained in:
Woon Tien Jing
2014-12-06 16:58:46 +08:00
parent 889be2cc3a
commit 0b0699f7b4
4 changed files with 25 additions and 1 deletions

View File

@@ -47,12 +47,18 @@
// Get user parameters
NSDictionary *params = (NSDictionary*) [command argumentAtIndex:0];
NSString * camera = [params objectForKey:@"camera"];
NSString *camera = [params objectForKey:@"camera"];
if([camera isEqualToString:@"front"]) {
// We do not set any specific device for the default "back" setting,
// as not all devices will have a rear-facing camera.
self.scanReader.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}
NSString *flash = [params objectForKey:@"flash"];
if([flash isEqualToString:@"on"]) {
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
} else if([flash isEqualToString:@"off"]) {
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
}
// Hack to hide the bottom bar's Info button... http://stackoverflow.com/a/16353530
UIView *infoButton = [[[[[self.scanReader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:3];