本文介绍了如何在Zbar SDK中设置相机闪光灯的亮度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ios应用中使用zbar sdk.我想使相机闪光灯变暗.在ios文档中,我找到了 AVCaptureDevice

I am using zbar sdk in my ios app. I want to dim the camera flash light.In ios documentation I have found AVCaptureDevice

- (BOOL)setTorchModeOnWithLevel:(float)torchLevel error:(NSError **)outError

在AVCaptureDevice类中,setTorchModeOnWithLevel函数将光照级别设置为0-1.在zbar sdk中,我在readerview类中找到了该对象我正在使用以下代码

In AVCaptureDevice class setTorchModeOnWithLevel function sets the light level between 0-1.In zbar sdk I have found this object in readerview classI am using following code

    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函数时,它在建议中什么都没有显示,而当我手动编写时,它给出了错误.

When I try to access AVCaptureDevice functions it show nothing in suggestion and when I write it manually then it give error.

[mDevice setTorchModeOnWithLevel:0.5 error:error];

如何使用AVCaptureDevice对象,以便设置闪光灯的暗度?

How I can use AVCaptureDevice object so that I can set the dim level of flash light??

推荐答案

我正在调用以下给出错误的函数

I was calling following function which give error

[mDevice setTorchModeOnWithLevel:0.5 error:error];

错误的原因是我没有在构建设置中包含AVFoundation库.包括我的错误后, @rakeshNS 我们可以通过使用

The reason of error was that I have not included AVFoundation library in build setting. After including my error resolves@rakeshNS we can dim the zbar sdk light by using

AVCaptureDevice *mDevice = mReader.readerView.device;
[mDevice setTorchModeOnWithLevel:0.5 error:nil];

谢谢大家

这篇关于如何在Zbar SDK中设置相机闪光灯的亮度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-07 23:39