Flash in zBar Camera

后端 未结 2 1062
北恋
北恋 2021-01-07 11:41

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 abou

2条回答
  •  抹茶落季
    2021-01-07 12:16

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

提交回复
热议问题