问题描述
我正在使用ZBAR进行Qr码扫描。我已经正确实现了ZBar。现在我想在Zbar中打开或关闭闪光灯。在ZBar网站上,我只能得到有关火炬的信息,但没有关于闪光灯的信息。 $ b
闪光灯是灯光闪烁一瞬间。 火炬是当灯光保持亮着的时候。你需要火炬,而不是闪光。如果光线只闪烁一秒钟,就很难扫描条形码。
我已经完成了您所寻找的任务。我在导航栏中添加了一个 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;
}
}
}
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;
}
}
}
这篇关于Flash在zBar相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!