Flash in zBar Camera

浪子不回头ぞ 提交于 2019-12-01 01:34:11

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