我有一 app用Zbar SDK I, 一切照旧,而且大刀切。 然而,当我试图扫描UPC-A条条码时(Grocery 只字),其编号与条码完全不同。
For example: I scan 03800051156 I get as a result: 156749328
你可以看到完全不同!
- (IBAction)scanButtonTapped
{
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: Set UPC-A
[scanner setSymbology: ZBAR_UPCA
config: ZBAR_CFG_ENABLE
to: 1];
// present and release the controller
[self presentModalViewController: reader
animated: YES];
[reader release];
}
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
// ADD: get the decode results
id<NSFastEnumeration> results =
[info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// EXAMPLE: just grab the first barcode
break;
//URL
NSString *urlString = symbol.data;
NSURL *url = [NSURL URLWithString:urlString];
[scanWebView loadRequest:[NSURLRequest requestWithURL:url]];
NSLog(@"Type UPC %d", symbol.type);
NSLog(@"Reader UPC %d", urlString);
AppDataObject* theDataObject = [self theAppDataObject];
theDataObject.UPC = urlString;
// EXAMPLE: do something useful with the barcode data
resultText.text = symbol.data;
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissModalViewControllerAnimated: YES];
// ADD Load the ProductInfo view after a slight delay to let the other VC resign.
[self performSelector:@selector(loadProduct) withObject:nil afterDelay:1.0];
}