Xcode 11 beta,典型的QRGenerator设置图像时使应用程序崩溃

时间:2019-07-09 22:26:56

标签: uiimageview swift5 xcode11

我试图将QRCode的UIImage设置为具有绑定等的情节提要上的ImageView上。这是我的标准QRGenerator函数:

func generateQRCode(from string: String) -> UIImage? {
    let data = string.data(using: String.Encoding.ascii)

    if let filter = CIFilter(name: "CIQRCodeGenerator") {
        filter.setValue(data, forKey: "inputMessage")
        let transform = CGAffineTransform(scaleX: 4, y: 4)

        if let output = filter.outputImage?.transformed(by: transform) {
            return UIImage(ciImage: output)
        }
    }

    return nil
}

然后在其中崩溃:

qrCodeImageView.image = generateQRCode(from: string!)! 

虽然这样的标准可行:

            qrCodeImageView.image =  UIImage.init(named: "img_qr_code_placeholder")

这是错误:

Metal API Validation Enabled
validateComputeFunctionArguments:817: failed assertion `Compute Function(mainMetalEntryPoint): Non-writeable texture format MTLPixelFormatRGBA8Unorm_sRGB is being bound at index 0 to a shader argument with write access enabled.'

0 个答案:

没有答案