iphone - 在 iphone 中扫描这么多次后,条形码阅读器 View 出现两次?

标签 iphone ios ipad barcode-scanner

我有一个使用条形码扫描的 iPad 应用程序。我正在使用 ZBarSDK 扫描条形码。像这样我正在呈现扫描 View 。`

// ADD: present a barcode reader that scans from the camera feed
        ZBarReaderViewController *reader = [ZBarReaderViewController new];
        reader.readerDelegate = self;

        reader.supportedOrientationsMask = ZBarOrientationMaskAll;

        reader.sourceType=UIImagePickerControllerSourceTypeCamera;
        //reader.cameraDevice = UIImagePickerControllerCameraDeviceFront;

        reader.cameraOverlayView=cameraOverlay;

        if( [UIImagePickerController isCameraDeviceAvailable:                         UIImagePickerControllerCameraDeviceFront ])
        {
            reader.cameraDevice = UIImagePickerControllerCameraDeviceFront;
        }
        ZBarImageScanner *scanner = reader.scanner;

        reader.wantsFullScreenLayout = YES;
        // 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];
        reader.showsZBarControls = NO; 
        // present and release the controller
        [self temporarilyHideStatusBar];  
        if(fromscan==YES)
        {
            [self presentModalViewController:reader animated:NO];
        }
        else
        {
            [self presentModalViewController:reader animated:YES];
        }

        [reader.view addSubview:back];
        [back addTarget:self action:@selector(backpressed:) forControlEvents:UIControlEventTouchUpInside];

        [reader release];

其次是

 - (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)
        // EXAMPLE: just grab the first barcode
        break;

  //commented blues  
    NSLog(@"%@",symbol.data);

     [self sdsdsd:symbol.data];

     [reader dismissModalViewControllerAnimated:YES];


}

sdssd 是我获取该数据的功能。所有 r 工作正常。但我的问题是在扫描一段时间后,当按下扫描覆盖层的按钮即将到来但不允许扫描时,覆盖层内有不同的绿色边界.当我们取消时,显示扫描已经完成。那就是我要从扫描开始的下一页。谁能知道为什么会这样?

最佳答案

试试这个

- (IBAction) scanButtonTapped
{
    // ADD: present a barcode reader that scans from the camera feed
    ZBarReaderViewController *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 presentModalViewController: reader
                            animated: YES];

}

- (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)
        // EXAMPLE: just grab the first barcode
        break;

    // EXAMPLE: do something useful with the barcode data
    resultText.text = symbol.data;

    // EXAMPLE: do something useful with the barcode image
    resultImage.image = [info objectForKey: UIImagePickerControllerOriginalImage];

    // ADD: dismiss the controller (NB dismiss from the *reader*!)
    [reader dismissModalViewControllerAnimated: YES];
}

关于iphone - 在 iphone 中扫描这么多次后,条形码阅读器 View 出现两次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12454892/

相关文章:

iphone - 交换 Root View Controller

iphone - iPhone上滚动时底部固定div不断跳跃

iphone - 在 View Controller 中使用多个 TableView 时使用委托(delegate)方法

ios - 在 swift 4.2 中交换数组值时检测到致命访问冲突

ios - 有没有办法通过 Apple 后端的一些 API 导出应用商店应用内支付?

ios4 - 多个MPMoviePlayerController实例

css - 为什么 border-radius 在 iPad 上看起来像垃圾?

iphone - 你能告诉我在 Facebook 应用程序中用于屏幕导航的控件的名称是什么吗?

iphone - iOS 中 iPhone 的 SAX XML 解析器示例

ios - 无法从 UITableViewCell 导出自定义类