我有一个使用Zbar SDK的应用程序我已经启动并运行了一切,它可以很好地扫描QR码。然而,当我尝试扫描UPC-A条形码(Grocery stuff)时,它会返回一个与条形码完全不同的数字。
例如:我扫描03800051156 结果我得到了: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];
}
答案 0 :(得分:1)
您将urlString
记录为小数,因此您打印的指针值为urlString
,而不是实际字符串的值。
尝试:
NSLog(@"Reader UPC %@", urlString);