QR code reader for iPhone

2019-01-20 23:44发布

问题:

I want to create QR code reader based application.

Using which library, I can create my application ?

Note: I searched in google. Always I am getting zxing. I downloaded the zxing project. But the problem is; I run the application. But it is reading only the Barcodes. There is no option to read QR code.

Please tell me how to do this...

Thanks in Advance.

回答1:

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.



回答2:

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


回答3:

Try ZXingObjC working great and easy to integrate.

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



回答4:

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.