![](/img/trans.png)
[英]When code is in loadView: Could not execute support code to read Objective-C class data in the process
[英]Ios crash “could not execute support code to read Objective-C” on ios 12.4.2 not on 12.0.1
该方法返回一个字符串的二维码图像。 它在 Ios 12.0.1 (iphone SE) 上正常工作,但在 12.4.2 (iphone 6) 上崩溃。 当我尝试将结果UIImage
分配给UIImageView
时,方法崩溃,结果UIImage
不为零。
-(UIImage*)get_QR_image :(NSString*)qrString :(UIColor*)ForeGroundCol :(UIColor*)BackGroundCol{
NSData *stringData = [qrString dataUsingEncoding: NSUTF8StringEncoding];
CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[qrFilter setValue:stringData forKey:@"inputMessage"];
[qrFilter setValue:@"H" forKey:@"inputCorrectionLevel"];
CIImage *qrImage = qrFilter.outputImage;
float scaleX = 320;
float scaleY = 320;
CIColor *iForegroundColor = [CIColor colorWithCGColor:[ForeGroundCol CGColor]];
CIColor *iBackgroundColor = [CIColor colorWithCGColor:[BackGroundCol CGColor]];
CIFilter * filterColor = [CIFilter filterWithName:@"CIFalseColor" keysAndValues:@"inputImage", qrImage, @"inputColor0", iForegroundColor, @"inputColor1", iBackgroundColor, nil];
CIImage *filtered_image = [filterColor valueForKey:@"outputImage"];
filtered_image = [filtered_image imageByApplyingTransform:CGAffineTransformMakeScale(scaleX, scaleY)];
UIImage *result_image = [UIImage imageWithCIImage:filtered_image
scale:[UIScreen mainScreen].scale
orientation:UIImageOrientationUp];
return result_image;
}
崩溃所涉及的线路是:
filtered_image = [filtered_image imageByApplyingTransform:CGAffineTransformMakeScale(scaleX, scaleY)];
它生成此日志:
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
我的方法中有些东西只适用于 12.0.1? 或者可能有什么问题? 我如何进行更多调查以解决该崩溃?
编辑
红色的我有:
MyQrCodeImageViewBig.image=qrimage;
带有消息:
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1a83e146c)
我看到[UIImage imageWithCIImage:]
初始化程序导致了很多问题。 主要问题是CIImage
实际上不包含任何 bitmap 数据。 它需要CIContext
渲染。 因此,您分配UIImage
的目标需要知道它由仍需要渲染的CIImage
支持。 通常UIImageView
处理得很好,但我不会太相信它。
您可以做的是将图像自己渲染为 bitmap ( CGImage
) 并用它初始化UIImage
。 为此,您需要一个CIContext
,我建议您在此方法之外的某个位置创建一次,并在每次需要渲染图像时重新使用它(这是一个昂贵的对象):
self.context = [CIContext context];
然后在您的方法中,您像这样渲染图像:
CGImageRef cgImage = [self.context createCGImage:filtered_image fromRect:[filtered_image extent]];
UIImage* result_image = [UIImage imageWithCGImage:cgImage];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.