如何从zbar获取代码的types?
在我的应用程序Zbar解码完美。 但问题是Zbar可以解码QR码和条码。 所以解码后如何获得编码风格的types?
提前致谢
在ZBarSymbol中有types的返回码。 您将需要为QR码寻找ZBAR_QRCODE
ZBarSymbol文档
像这样的东西应该可以帮助你获得符号:
- (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 }