ios - 尝试打开相机 View 时 zbar 卡住

标签 ios barcode-scanner zbar-sdk

我正在使用 zbar sdk 扫描条形码。问题是有时它在尝试打开相机 View 时会卡住。这可能需要 1-4 分钟。它太长而且很烦人,但有时它打开得很快。我该如何解决这个问题?谢谢。

-(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];
}

//将这一行放在 viewDidLoad 方法中。

关于ios - 尝试打开相机 View 时 zbar 卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23288127/

相关文章:

ios - 如何快速将对象设置为 NSMutableDictionary 中的键

ios - NSLocalized 从字符串文件创建不同的字符串

c# - 文本框中的扫描值(使用扫描仪)

java - 适用于 Android 的 Zxing 条码匹配应用程序

iphone - zbar sdk 无法通过使用相机模拟器在 iPhone 模拟器上工作

ios - 使用 Microsoft Band 检索心率

iOS 编程 : UITextField, 监听 unfocus 事件

javascript - HIdDevice.fromIdAsync 始终返回 null

objective-c - 在 UIView 中实现 ZBar 二维码阅读器

iphone - zbar应用中扫描页面的自定义