在我的应用程序中,Zbar可以完美解码。但是问题是Zbar可以同时解码QR码和条形码。因此,解码后,如何获得编码样式的类型?
ZBarSymbol中有类型的返回码。您将在寻找ZBAR_QRCODE的QR码
这样的事情应该可以帮助您删除符号:
- (void) readerView: (ZBarReaderView*) view didReadSymbols: (ZBarSymbolSet*) syms fromImage: (UIImage*) img
{
//do something useful with results and display resultText in resultViewController
for(ZBarSymbol *sym in syms)
{
imageResult3.image = img;
resultText.text = sym.typeName;
resultText.text = [ resultText.text stringByAppendingString:@" - " ];
resultText.text = [ resultText.text stringByAppendingString:sym.data ];
}
}
我所做的是,
- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];
ZBarImage *zImage = [[ZBarImage alloc] initWithCGImage:image.CGImage];
ZBarImageScanner *scanner = [[ZBarImageScanner alloc] init];
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
[scanner scanImage:zImage];
ZBarSymbolSet *set = [scanner results];
ZBarSymbol *symbol = nil;
for (symbol in set)
break;
codeType.text = symbol.typeName
}