Khu*_*hah 6 iphone camera ipod objective-c barcode-scanner
我正在使用后置摄像头来读取条形码数据...它正在完美扫描.现在我想使用前置摄像头......我该怎么做?我应该在哪里进行更改?我使用过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];
}
Run Code Online (Sandbox Code Playgroud)
如果我正确理解你的问题,你所要做的就是打开你的相机而不是后方模式,所以在你第一次调用选择器的方法中写下这个:
picker.cameraDevice=UIImagePickerControllerCameraDeviceFront;
Run Code Online (Sandbox Code Playgroud)
希望这能回答你的问题.如果没有,请告诉我.
| 归档时间: |
|
| 查看次数: |
4121 次 |
| 最近记录: |