iphone - 在屏幕的某些部分打开 zbar 扫描仪
<p><p>我有一个应用程序,我在其中使用 ZBar 实现了二维码扫描。</p>
<p>现在我还在相机上实现了覆盖。</p>
<p>问题是虽然我做了一个覆盖,相机扫描整个屏幕的一部分。</p>
<p>我想在屏幕的某个部分进行扫描。</p>
<p>这是我的代码,</p>
<pre><code> reader = ;
isCameraStarted = YES;
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
//Add flash Camera
if(isTorchOn==NO)
reader.cameraFlashMode=UIImagePickerControllerCameraFlashModeOff;
else
reader.cameraFlashMode=UIImagePickerControllerCameraFlashModeOn;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
;
[scanner setSymbology:ZBAR_QRCODE
config:ZBAR_CFG_ENABLE
to:1];
reader.cameraOverlayView = vw;
reader.showsZBarControls=NO;
;
;
</code></pre>
<p>在中间的方形方框中打开相机</p>
<p>这是我想要的输出:</p>
<p> <img src="/image/WBbbn.png" alt=""/> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>尝试使用 ZBarReaderView,而不是使用 ZBarReaderViewController。
下面的链接对我有用。</p>
<pre><code>- (void)startScanning{
NSLog(@"Scanning..");
ZBarReaderView*reader = ;
ZBarImageScanner * scanner = ;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
reader = ;
reader.readerDelegate = self;
reader.tracksSymbols = YES;
reader.frame = CGRectMake(10, 100, - 20, -200);
reader.torchMode = 0;
dispatch_async(dispatch_get_main_queue(), ^{;});
;
}
-(void) readerView:(ZBarReaderView *)readerView didReadSymbols:(ZBarSymbolSet * )symbols fromImage :(UIImage *)image
{
for (ZBarSymbol *sym in symbols)
{
NSLog(@"Scanned data: %@", sym.data);
break;
}
;
// action todo
}
</code></pre>
<p>希望能帮到你。</p></p>
<p style="font-size: 20px;">关于iphone - 在屏幕的某些部分打开 zbar 扫描仪,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/18182718/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/18182718/
</a>
</p>
页:
[1]