yeahdongcn / RSBarcodes

1D and 2D barcodes scanner and generators for iOS7 with delightful controls.
MIT License
383 stars 59 forks source link

UPC-A support #29

Open yporubov opened 9 years ago

yporubov commented 9 years ago

Thank you so much for the barcode generator.

From "AVMetadataObjectTypeEAN13Code" description: AVMetadataMachineReadableCodeObject instances generated from EAN-13 (including UPC-A) codes return this identifier as the type.

The barcode does have length 12 digits, like 123456789012. EAN-13 barcode does have 13 digits isContentsValid method returns NO because contents.length == self.length is not TRUE. (12 != 13) As workaround I added one zero before barcode (0123456789012) and it works for me. [CodeGen genCodeWithContents:@"0123456789012" machineReadableCodeObjectType:objectType]

But could you please add zero inside API ?

Reinoal commented 8 years ago

首先感谢你的分享,我使用的版本是0.1.4 在扫描二维码的结束,controller被退出之后alert会被多次调用并显示。怎么解决这个问题: if (barcodeObjects.count > 0) { [barcodeObjects enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL stop) { dispatch_async(dispatch_get_main_queue(), ^{ AVMetadataMachineReadableCodeObject code = obj; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Barcode found" message:code.stringValue delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; dispatch_async(dispatch_get_main_queue(), ^{ [scanner dismissViewControllerAnimated:true completion:nil]; [alert show]; });