我有一个使用条形码扫描的 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/