iphone - 如何在ipod中使用前置摄像头进行条码扫描

标签 iphone objective-c camera ipod 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];
                     }

最佳答案

如果我对你的问题的理解正确,你所要做的就是打开你的相机,使其处于前置模式而不是后置模式,所以在你第一次调用选择器的方法中写这个:

  picker.cameraDevice=UIImagePickerControllerCameraDeviceFront;

希望这能回答您的问题。如果没有,请告诉我。

关于iphone - 如何在ipod中使用前置摄像头进行条码扫描,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9237962/

相关文章:

iphone - Xcode 调试器(适用于 iPhone)中的 "out of scope"是什么意思?

iphone - iOS7 忽略视网膜 css 媒体查询 - 背景大小

android - Android 4.1(API 级别 16)中相机崩溃

iOS 拍照并保存在应用程序中

iphone - MATLAB 监听 TCP/IP 端口

iphone - Objective-C class_conformsToProtocol() 错误?

ios - SKPhysicsBody 不适用于 SKShapeNode

ios - disableUndoRegistration仍允许撤消操作

ios - 在特定日期重复 UILocalNotification

iphone - 在 UIView 中嵌入实时摄像头 View