Ios 在 ios 12.4.2 而非 12.0.1 上崩溃 "could not execute support code to read Objective-C"
Ios crash "could not execute support code to read Objective-C" on ios 12.4.2 not on 12.0.1
此方法returns一个字符串的二维码图片。它在 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
实际上不包含任何位图数据。它需要先由 CIContext
渲染。因此,您分配 UIImage
的目标需要 知道 它由仍然需要渲染的 CIImage
支持。通常 UIImageView
处理得很好,但我不会太相信它。
你可以做的是将图像自己渲染成位图 (CGImage
) 并用它初始化 UIImage
。你需要一个 CIContext
,我建议你在这个方法之外的某个地方创建一次 once 并在每次需要渲染图像时重新使用它(它是一个昂贵的对象) :
self.context = [CIContext context];
然后在您的方法中,您渲染图像如下:
CGImageRef cgImage = [self.context createCGImage:filtered_image fromRect:[filtered_image extent]];
UIImage* result_image = [UIImage imageWithCGImage:cgImage];
此方法returns一个字符串的二维码图片。它在 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
实际上不包含任何位图数据。它需要先由 CIContext
渲染。因此,您分配 UIImage
的目标需要 知道 它由仍然需要渲染的 CIImage
支持。通常 UIImageView
处理得很好,但我不会太相信它。
你可以做的是将图像自己渲染成位图 (CGImage
) 并用它初始化 UIImage
。你需要一个 CIContext
,我建议你在这个方法之外的某个地方创建一次 once 并在每次需要渲染图像时重新使用它(它是一个昂贵的对象) :
self.context = [CIContext context];
然后在您的方法中,您渲染图像如下:
CGImageRef cgImage = [self.context createCGImage:filtered_image fromRect:[filtered_image extent]];
UIImage* result_image = [UIImage imageWithCGImage:cgImage];