美文网首页
iOS中识别二维码信息

iOS中识别二维码信息

作者: 杨闯 | 来源:发表于2020-01-22 06:29 被阅读0次
    //1.创建一个二维码探测器
    CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy : CIDetectorAccuracyHigh}];
            
    //2.探测二维码的特征
    CIImage *ciImage = [CIImage imageWithCGImage:image.CGImage];
            NSArray *qrCodeFeatures = [detector featuresInImage:ciImage];
            
    NSString *content = nil;
    //3.对识别出来的CIQRCodeFeature 进行遍历,如果发现了二维码信息,则会把二维码信息赋值给content
    for (CIQRCodeFeature *feature in qrCodeFeatures) {
        if ([feature isKindOfClass:[CIQRCodeFeature class]] && feature.messageString.length) {
              content = feature.messageString;
               break;
          }
    }
    

    相关文章

      网友评论

          本文标题:iOS中识别二维码信息

          本文链接:https://www.haomeiwen.com/subject/auenectx.html