1

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

// 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 工作正常。但我的问题是在扫描了一段时间后,按下用于扫描覆盖的按钮即将到来但不允许扫描,该覆盖内有一个不同的绿色边框。当我们取消显示,就像扫描已经完成一样。这就是我要从扫描开始的下一页。任何人都可以知道为什么会这样吗?

4

1 回答 1

-1

尝试这个

- (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];
}
于 2012-09-17T07:43:20.200 回答