ios - IOS 最好的 QR 阅读器库是什么?

标签 ios iphone qr-code

<分区>


我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。

关闭 6 年前

我想在我的 iOS 应用程序中使用 QR 阅读器库。 IOS 最好的 QR 阅读器库是什么? 我在 github 上找到了一些,但不确定是否可以。

最佳答案

在 ios7 和更新版本上试试这个

获取二维码:

- (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];
}

读取使用它的委托(delegate)方法:

- (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;
}

关于ios - IOS 最好的 QR 阅读器库是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41238838/

上一篇:ios - 构建期间的 provisioningProfile 冲突

下一篇:ios - 是否可以在iBeacon上写入数据

相关文章:

html - ios 上自定义图标字体上的奇怪水平线

ios - 结合导航 Controller 和标签栏 Controller

iphone - UITableViewController 内容未出现

java - Android 应用程序中的二维码扫描仪

ios - Swift--读取JSON文件

objective-c - 将 UIScrollView 锁定在特定页面上(pagingEnabled)

iphone - 添加到项目包时映射资源

ios - 如何使用 AFNetworking 3.0 在后台下载大文件并在 session 完成所有任务时显示本地通知

android - 如何在android中将 Logo 设置为QR码中间

java - 如何修复找不到符号方法bitmap()?