我正在使用后置摄像头读取条码数据...并且扫描效果非常好。现在我想使用前置摄像头...我该怎么做?我应该在哪里找零?我用过ZBar条码阅读器
我的代码是:
- (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];
[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;
// EXAMPLE: do something useful with the barcode data
resultText.text = symbol.data;
bid.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];
}
最佳答案
如果我对你的问题的理解正确,你所要做的就是打开你的相机,使其处于前置模式而不是后置模式,所以在你第一次调用选择器的方法中写这个:
picker.cameraDevice=UIImagePickerControllerCameraDeviceFront;
希望这能回答您的问题。如果没有,请告诉我。
关于iphone - 如何在ipod中使用前置摄像头进行条码扫描,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9237962/