QR code reader for iPhone

偶尔善良 提交于 2019-11-28 15:18:09

ZBarSDK is another option. A very capable library.

UPDATE January 2014

Beginning in iOS7, AVCaptureDevice now includes the ability to read barcodes (of all kinds) and return a human readable value. If you're targeting iOS7+, this is the way to go. ZBarSDK is still great for pre-iOS7 support, of course.

iGo

AVCaptureMetaDataOutput - Starting from iOS 7

Scan UPCs, QR codes, and barcodes of all varieties with AVCaptureMetaDataOutput, new to iOS 7. All you need to do is set it up as the output of an AVCaptureSession, and implement the captureOutput:didOutputMetadataObjects:fromConnection: method accordingly:

 @import AVFoundation;

 AVCaptureSession *session = [[AVCaptureSession alloc] init];
 AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
 NSError *error = nil;

 AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device
                                                                error:&error];
 if (input) {
     [session addInput:input];
 } else {
     NSLog(@"Error: %@", error);
 }

 AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] init];
 [output setMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]];
 [output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
 [session addOutput:output];

 [session startRunning];

 #pragma mark - AVCaptureMetadataOutputObjectsDelegate

 - (void)captureOutput:(AVCaptureOutput *)captureOutput
         didOutputMetadataObjects:(NSArray *)metadataObjects
              fromConnection:(AVCaptureConnection *)connection
   {
    NSString *QRCode = nil;
     for (AVMetadataObject *metadata in metadataObjects) {
       if ([metadata.type isEqualToString:AVMetadataObjectTypeQRCode]) {
            // This will never happen; nobody has ever scanned a QR code... ever
             QRCode = [(AVMetadataMachineReadableCodeObject *)metadata stringValue];
             break;
          }
      }

     NSLog(@"QR Code: %@", QRCode);
   }

AVFoundation supports every code you've heard of (and probably a few that you haven't):

AVMetadataObjectTypeUPCECode
AVMetadataObjectTypeCode39Code
AVMetadataObjectTypeCode39Mod43Code
AVMetadataObjectTypeEAN13Code
AVMetadataObjectTypeEAN8Code
AVMetadataObjectTypeCode93Code
AVMetadataObjectTypeCode128Code
AVMetadataObjectTypePDF417Code
AVMetadataObjectTypeQRCode
AVMetadataObjectTypeAztecCode

Try ZXingObjC working great and easy to integrate.

As well, you can define the size of the scanner window inside your view.

for your reference you can use webqr.com and it's library you can use for decode the QR code and encoding also . But for different browser like safari, Chrome, IE, Firefox, you can add the plugin for This. Hope so it will help full for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!