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.
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