I'm using zbar sdk to scan barcodes. The problem is sometimes it freezes while trying to open the camera view. It can takes 1-4 minutes. It is too long and annoying, but sometimes it opens quickly. How can I solve this issue? Thanks.
-(void)barcodeRead
{
reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
// present and release the controller
[self presentViewController: reader
animated: YES completion:nil];
}
- (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)
break;
// EXAMPLE: do something useful with the barcode image
if(whichbtn==1){pushed=1;
resultText1.text=symbol.data;
resultImage1.image= [info objectForKey: UIImagePickerControllerOriginalImage];
}else{if(whichbtn==2){pushed=1;
resultText2.text=symbol.data;
resultImage2.image= [info objectForKey: UIImagePickerControllerOriginalImage];
}
}
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissViewControllerAnimated: YES completion:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
reader = [ZBarReaderViewController new];
}
//put this line in viewDidLoad method.