谢谢
import UIKitclass VIEwController: UIVIEwController { @IBOutlet weak var myimage: UIImageVIEw! overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // Do any additional setup after loading the vIEw,typically from a nib. let image = CIImage(image: myimage.image) let filter = CIFilter(name: "CISepiaTone") filter.setDefaults() filter.setValue(image,forKey: kCIInputimageKey) myimage.image = UIImage(CIImage: filter.outputimage) self.reapplyFilter() } func reapplyFilter(){ let image = CIImage(image: myimage.image) let filter = CIFilter(name: "CISepiaTone") filter.setDefaults() filter.setVa lue(image,forKey: kCIInputimageKey) //ERROR HERE: Fatal error: unexpectedly found nil while unwrapPing an Optional value myimage.image = UIImage(CIImage: filter.outputimage)//ERROR } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. }}解决方法 你不能调用UIImage(CIImage :)并使用UIImage作为UIImageVIEw的图像. UIImageVIEw需要一个由位图(CGImage)支持的UIImage.用CIImage实例化的UIImage没有位图;它没有实际图像,它只是一组应用过滤器的指令.这就是你的UIImageVIEw图像为零的原因. 总结
以上是内存溢出为你收集整理的ios – CIFilter输出图像为零全部内容,希望文章能够帮你解决ios – CIFilter输出图像为零所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)