Flash in zBar Camera

不羁岁月 提交于 2019-11-30 20:08:25

问题


I am using ZBAR for Qr code scanning. I had implemented ZBar correctly. Now I want to make flash light on or off in Zbar.

On ZBar website I only get information about Torch but no information about flash light.


回答1:


The "flash" is when the light "flashes" for a split second. The "torch" is when the light stays on. You do want "torch", not "flash". It would be hard to scan a barcode if the light only flashed for a split second.

I've done what you are look for. I added a UIBarButtonItem to the navbar. I created the button with a custom image. The button handler is as follows:

- (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;
        }
    }
}


来源:https://stackoverflow.com/questions/15263296/flash-in-zbar-camera

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!