标签:bounds ide ntc rac code sof options contex graphics
//截图 再读取
UIGraphicsBeginImageContextWithOptions(currentImageView.bounds.size, YES, 0);//currentImageView 图片VIEW
CGContextRef context = UIGraphicsGetCurrentContext();
[self.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//识别二维码
CIImage *ciImage = [[CIImage alloc] initWithCGImage:image.CGImage options:nil];
CIContext *ciContext = [CIContext contextWithOptions:@{kCIContextUseSoftwareRenderer : @(YES)}]; // 软件渲染
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:ciContext options:@{CIDetectorAccuracy : CIDetectorAccuracyHigh}];// 二维码识别
NSArray *features = [detector featuresInImage:ciImage];//手机连接Xcode运行到这就出问题 但是在手机上 运行没问题
for (CIQRCodeFeature *feature in features) {
NSLog(@"msg = %@",feature.messageString); // 打印二维码中的信息
//对结果进行处理
}
标签:bounds ide ntc rac code sof options contex graphics
原文地址:https://www.cnblogs.com/xiaodeng90/p/8782675.html