Search code examples
iphoneipadios6barcode-scannerzbar-sdk

ZBarReader Scans Only UPC_A format in iOS 6


I am developing BarCode reader app in iOS 6,

I am using ZBar sdk, i developed app using this Tutorial.. when i scans any barcode it scans only product of UPC format, but it doesn't scans the product of any other format like EAN_13 or Code_128 etc..

Here is my code snippet,

- (IBAction) scanButtonTapped
{

    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;
    reader.supportedOrientationsMask = ZBarOrientationMaskAll;

    ZBarImageScanner *scanner = reader.scanner;

    [scanner setSymbology: ZBAR_I25
                   config: ZBAR_CFG_ENABLE
                       to: 0];

    [self presentViewController:reader animated:YES completion:nil];

}

- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    id<NSFastEnumeration> results =
    [info objectForKey: ZBarReaderControllerResults];
    ZBarSymbol *symbol = nil;
    for(symbol in results)
        break;

    NSLog(@"symbol.data=%@",symbol.data);

    [reader dismissViewControllerAnimated:YES completion:nil];

}

How to scan product of all type ? any idea ?


Solution

  • From the Zbar FAQs

    The ZBar decoder enables only EAN-13 by default

    and

    The UPC-A symbology is the subset of EAN-13 that starts with a leading 0... You can choose to receive the 12-digit results instead by explicitly enabling UPC-A.

    It sounds like EAN 13 is enabled. To enable Code 128, put the following snippet after you disable Interleaved 2 of 5 (I25)

    [scanner setSymbology: ZBAR_CODE128
         config: ZBAR_CFG_ENABLE
         to: 1];
    

    If you want strict control over what is enabled and disabled, disable all symbologies and selectively enable the ones you want

    // Disable all symbologies
    [scanner setSymbology: 0
         config: ZBAR_CFG_ENABLE
         to: 0];
    // Enable EAN 13
    [scanner setSymbology: ZBAR_EAN13
         config: ZBAR_CFG_ENABLE
         to: 1];
    // Enable UPC-A
    [scanner setSymbology: ZBAR_UPCA
         config: ZBAR_CFG_ENABLE
         to: 1];
    // Enable Code 128
    [scanner setSymbology: ZBAR_CODE128
         config: ZBAR_CFG_ENABLE
         to: 1]