2016-12-20 10 views
-1

私のiosアプリケーションでQRリーダーライブラリを使いたいです。 IOSのための最良のQRリーダーライブラリは何ですか? 私はgithubでいくつかを見つけましたが、確かに大丈夫かどうかはわかりません。IOSのための最良のQRリーダーライブラリは何ですか?

+0

チェックアウトhttps://www.appcoda com/qr-code-reader-swift/ – Amanpreet

+0

zBarが最も使用されているライブラリです。機能が制限されている場合は、ネイティブのカメラでqrをスキャンします –

答えて

1

iOS版が既にQRリーダーが

3

QRコードキャプチャするios7以降

でこれをしようとそれを実装する方法についてのiOS 7、here is a tutorialからAVFoundationに実装されています読むには

- (IBAction)Capture:(id)sender { 

    isFirst=true; 
_session = [[AVCaptureSession alloc] init]; 
    _device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 
    NSError *error = nil; 

    _input = [AVCaptureDeviceInput deviceInputWithDevice:_device error:&error]; 
    if (_input) { 
     [_session addInput:_input]; 
    } else { 
     NSLog(@"Error: %@", error); 
    } 

    _output = [[AVCaptureMetadataOutput alloc] init]; 
    [_output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()]; 
    [_session addOutput:_output]; 

    _output.metadataObjectTypes = [_output availableMetadataObjectTypes]; 

    _prevLayer = [AVCaptureVideoPreviewLayer layerWithSession:_session]; 
    _prevLayer.frame = self.view.bounds; 
    _prevLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 
    [self.view.layer addSublayer:_prevLayer]; 

    [_session startRunning]; 
} 

をデリゲートメソッドを使用してください:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection 
{ 
    CGRect highlightViewRect = CGRectZero; 
    AVMetadataMachineReadableCodeObject *barCodeObject; 
    NSString *detectionString = nil; 
    NSArray *barCodeTypes = @[AVMetadataObjectTypeUPCECode, AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeCode39Mod43Code, 
      AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode93Code, AVMetadataObjectTypeCode128Code, 
      AVMetadataObjectTypePDF417Code, AVMetadataObjectTypeQRCode, AVMetadataObjectTypeAztecCode]; 

    for (AVMetadataObject *metadata in metadataObjects) { 
     for (NSString *type in barCodeTypes) { 
      if ([metadata.type isEqualToString:type]) 
      { 
       barCodeObject = (AVMetadataMachineReadableCodeObject *)[_prevLayer transformedMetadataObjectForMetadataObject:(AVMetadataMachineReadableCodeObject *)metadata]; 
       highlightViewRect = barCodeObject.bounds; 
       detectionString = [(AVMetadataMachineReadableCodeObject *)metadata stringValue]; 
       break; 
      } 
     } 

     if (detectionString != nil) 
     { 
      if (isFirst) { 
      isFirst=false; 
      _label.text = detectionString; 
      break; 
      } 
     } 
     else 
      _label.text = @"(none)"; 
    } 

    _highlightView.frame = highlightViewRect; 
} 
関連する問題