这是我滤波器的代码:如何在iOS中的图像上应用CIPhotoEffectMono过滤器?
let filter = CIFilter(name: "CIPhotoEffectMono")
filter!.setValue(CIImage(image: imageView.image!) , forKey: kCIInputImageKey)
filter!.setValue(0.3, forKey: kCIInputIntensityKey)
let context = CIContext(options:nil)
let cgimg = context.createCGImage(filter!.outputImage!, fromRect: filter!.outputImage!.extent)
let newImage = UIImage(CGImage:cgimg)
self.imageView.image = newImage
以下是错误消息:
终止应用程序由于未捕获的异常 'NSUnknownKeyException',原因:“[setValue方法:forUndefinedKey:]:这个类不是关键输入密码的关键值编码。“
第一掷调用堆栈: (
0的CoreFoundation 0x0000000105f9af65 __exceptionPreprocess + 165
1 libobjc.A。dylib 0x0000000107f56deb objc_exception_throw + 48
2的CoreFoundation 0x0000000105f9aba9 - [NSException提高] + 9
3 CoreImage 0x0000000106354f7a - [CIFilter的setValue:forUndefinedKey:] + 137
4基金会0x000000010668af5b - [NSObject的(的NSKeyValueCoding)的setValue :forKey:] + 288
5 MyFirstApp 0x0000000105a26bac _TFC10MyFirstApp14ViewController13lightBlendBtnfS0_FPSs9AnyObject_T_ + 988
6 MyFir斯塔普0x0000000105a27076 _TToFC10MyFirstApp14ViewController13lightBlendBtnfS0_FPSs9AnyObject_T_ + 54
7的UIKit 0x0000000106ae01fa - [UIApplication的sendAction:为:从:forEvent:] + 92
8的UIKit 0x0000000106c44504 - [UIControl sendAction:至:forEvent:] + 67
9 UIKit的0x0000000106c447d0 - [UIControl _sendActionsForEvents:withEvent:方法] + 311
10的UIKit 0x0000000106c43906 - [UIControl touchesEnded:withEvent:方法] + 601
11的UIKit 0x0000000106b4aaa3 - [一个UIWindow _sendTouchesForEvent:] + 835
12的UIKit 0x0000000106b4b691 - [一个UIWindow的SendEvent:] + 865
13的UIKit 0x0000000106afd752 - [UIApplication的的SendEvent:] + 263
14的UIKit 0x00000001140f4a55 - [UIApplicationAccessibility的SendEvent:] + 77
15的UIKit 0x0000000106ad8fcc _UIApplicationHandleEventQueue + 6693
16的CoreFoundation 0x0000000 105ec70a1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
17的CoreFoundation 0x0000000105ebcfcc __CFRunLoopDoSources0 + 556
18的CoreFoundation 0x0000000105ebc483 __CFRunLoopRun + 867
19的CoreFoundation 0x0000000105ebbe98 CFRunLoopRunSpecific + 488个
20 GraphicsServices 0x000000010cdccad2 GSEventRunModal + 161
21 UIKit 0x0000000106ade676 UIApplicationMain + 171
22 MyFirstApp 0x0000000105a29fed主+ 109
23 libdyld.dylib 0x0000000108a8292d启动+ 1
)
的libC++ ABI。dylib:与类型NSException (LLDB)的未捕获的异常终止