微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – – [UIImage _imageByUnpremultiplying]:发送到实例的无法识别的选择器

我正在使用CI过滤器并得到奇怪的错误,我怎么能通过查看登录来了解我所缺少的内容

CIFilter *filter = [CIFilter filterWithName:@"CIFalseColor"];        
    [filter setValue:image forKey:@"inputimage"];
    CIColor *myBlue = [CIColor colorWithRed:0.0 green:0.0 blue:0.6 alpha:0.5];
    [filter setValue:myBlue forKey:@"inputColor0"];
    CIImage *filteredImageData = [filter valueForKey:@"outputimage"];
    UIImage *newImage = [UIImage imageWithCIImage:filteredImageData];
     _imageView.image=newImage;



2014-02-22 16:04:12.002 colorMaker[1574:70b] *** Terminating app due to uncaught exception 'NSinvalidargumentexception',reason: '-[UIImage _imageByUnpremultiplying]: unrecognized selector sent to instance 0x8b7aca0'

libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

解决方法

如果您设置为“inputimage”的对象是UIImage,则会发生此异常.根据 documentation,inputimage对象必须是CIImage.

首先尝试从你的UIImage获得CIImage.

[filter setValue:image.CIImage forKey:@"inputimage"];
                       ^^^^^^^

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐