문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top