简体   繁体   English

Ios 崩溃“无法执行支持代码以读取 Objective-C”在 ios 12.4.2 上不在 12.0.1

[英]Ios crash “could not execute support code to read Objective-C” on ios 12.4.2 not on 12.0.1

This method returns a qr code image of a string.该方法返回一个字符串的二维码图像。 It works correctly on Ios 12.0.1 (iphone SE) but it crash on 12.4.2 (iphone 6).它在 Ios 12.0.1 (iphone SE) 上正常工作,但在 12.4.2 (iphone 6) 上崩溃。 The method crash when i try to assign the resultant UIImage to an UIImageView , the resultant UIImage is not nil.当我尝试将结果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;
}

the line involved in crash is:崩溃所涉及的线路是:

filtered_image = [filtered_image imageByApplyingTransform:CGAffineTransformMakeScale(scaleX, scaleY)];

it generates this log:它生成此日志:

warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.

There's something in my method that works only on 12.0.1?我的方法中有些东西只适用于 12.0.1? Or maybe something wrong?或者可能有什么问题? How i can investigate more to solve that crash?我如何进行更多调查以解决该崩溃?

EDIT编辑

在此处输入图像描述

in red i have:红色的我有:

MyQrCodeImageViewBig.image=qrimage;

with messagge:带有消息:

Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1a83e146c)

I see a lot of problems resulting from the [UIImage imageWithCIImage:] initializer.我看到[UIImage imageWithCIImage:]初始化程序导致了很多问题。 The main problem being that a CIImage does not actually contain any bitmap data.主要问题是CIImage实际上不包含任何 bitmap 数据。 It needs to be rendered by a CIContext first.它需要CIContext渲染。 So the target you assign the UIImage to needs to know that it is backed by a CIImage that still needs rendering.因此,您分配UIImage的目标需要知道它由仍需要渲染的CIImage支持。 Usually UIImageView handles this well, but I wouldn't trust it too much.通常UIImageView处理得很好,但我不会太相信它。

What you can do instead is to render the image yourself into a bitmap ( CGImage ) and initialize the UIImage with that instead.您可以做的是将图像自己渲染为 bitmap ( CGImage ) 并用它初始化UIImage You need a CIContext for that, which I recommend you create somewhere outside this method once and re-use it every time you need to render an image (it's an expensive object):为此,您需要一个CIContext ,我建议您在此方法之外的某个位置创建一次,并在每次需要渲染图像时重新使用它(这是一个昂贵的对象):

self.context = [CIContext context];

Then in your method, you render the image like this:然后在您的方法中,您像这样渲染图像:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM