我在我的 ios 应用程序中使用 zbar sdk。我想调暗相机闪光灯。在 ios 文档中,我找到了AVCaptureDevice
- (BOOL)setTorchModeOnWithLevel:(float)torchLevel error:(NSError **)outError
在 AVCaptureDevice 类中,setTorchModeOnWithLevel 函数将光照级别设置在 0-1 之间。在 zbar sdk 中,我在 readerview 类中找到了这个对象,我正在使用以下代码
ZBarReaderViewController *mReader = [[ZBarReaderViewController alloc] init];
mReader.showsZBarControls = NO;
mReader.showsHelpOnFail = NO;
mReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
mReader.readerDelegate = self;
// reader.cameraDevice = UIImagePickerControllerCameraDeviceFront;
mReader.supportedOrientationsMask = ZBarOrientationMaskAll;
CGRect cropRect = CGRectMake(0, 0, cameraView.frame.size.width , cameraView.frame.size.height);
mReader.view.frame = cropRect;
mReader.cameraOverlayView = [self setOverlayPickerView];
AVCaptureDevice *mDevice = mReader.readerView.device; //mReader.readerView.device returns object of AVCaptureDevice
当我尝试访问 AVCaptureDevice 函数时,它没有显示任何建议,当我手动编写它时,它会给出错误。
[mDevice setTorchModeOnWithLevel:0.5 error:error];
如何使用 AVCaptureDevice 对象来设置闪光灯的暗淡程度?