感谢您检查我的帖子。无法调试EXC BAD ACCESS代码1
因此,行image!.drawInRect(rect!)
,我得到EXC_BAD_ACCESS代码1错误,我无法弄清楚我的生活。我在运行方案中启用了僵尸,并没有打印出来(也许我也做错了?),我有println()看起来像我所有的变量,没有什么是零。
我想说明的是,这段代码可以工作两次,然后大部分时间第三次调用失败。在我的应用程序中,您拍摄一张照片,然后您需要编辑照片(当调用此功能时)。当我回到我的相机拍摄照片并返回进行编辑(第三次)时,出现此错误。
此外,这种方法被称为在viewDidAppear()
任何帮助理解。我即将把我的头发拉出来!
var rect: CGRect?
var image: UIImage?
func convertCIImageToUIImage(cIImage: CIImage) -> UIImage {
println(cIImage)
let size: CGSize = filteredImageView.inputImage.size
println(filteredImageView.inputImage.size)
UIGraphicsBeginImageContext(size)
rect = CGRect(origin: CGPointZero, size: size)
image = UIImage(CIImage: filteredImageView.filter.outputImage)
println(UIGraphicsGetCurrentContext())
println("size: \(size)")
printAllObjects()
println()
image!.drawInRect(rect!)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
image = nil
rect = nil
let finalImage = UIImage(CGImage: newImage.CGImage!, scale: 1.0, orientation: UIImageOrientation.Right)
return finalImage!
}
嘿谢谢你的回复。所以把我的评论注释掉了,换上你的。同样的事情正在发生。它在'safeImage.drawInRect(safeRect)'上失败。很奇怪。任何其他想法? – justColbs
在Playground中粘贴你的代码给了我很多有关'filteredImageView'的错误。它是什么? – MustangXY
这是一个自定义类。我解决了这个问题。在下面检查。 – justColbs