在zBar相机中闪光

1 iphone flash ios zbar

我正在使用ZBAR进行Qr代码扫描.我已正确实施ZBar.现在我想在Zbar中打开或关闭闪光灯.

在ZBar网站上,我只获得有关Torch的信息,但没有关于闪光灯的信息.

rma*_*ddy 6

"闪光"是指灯"闪烁"一瞬间."火炬"就是灯光持续亮起的时候.你想要"火炬",而不是"闪光".如果灯只闪烁一秒钟就很难扫描条形码.

我做了你想要的.我UIBarButtonItem在导航栏中添加了一个.我创建了一个带有自定义图像的按钮.按钮处理程序如下:

- (void)torchToggle:(UIBarButtonItem *)button {
    if (button.style == UIBarButtonItemStyleBordered) {
        self.readerView.torchMode = AVCaptureTorchModeOff;
        if (self.readerView.torchMode == AVCaptureTorchModeOff) {
            button.style = UIBarButtonItemStyleDone;
        }
    } else {
        self.readerView.torchMode = AVCaptureTorchModeOn;
        if (self.readerView.torchMode != AVCaptureTorchModeOff) {
            button.style = UIBarButtonItemStyleBordered;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 添加以下导入:`#import <AVFoundation/AVFoundation.h>` (2认同)