当我尝试实现CIHueAdjust时出现错误。该应用程序终止时出现如下错误: - [CIImage doubleValue]:无法识别的选择器发送到实例0xd6606d0
以下是整个项目:owolf.net/uploads/StackOverflow/HueAdjustProject.zip
这是.m代码:
- (void)viewDidLoad
{
context = [CIContext contextWithOptions:nil];
hueFilter = [CIFilter filterWithName:@"CIHueAdjust"];
inputCGImage = imageView.image.CGImage;
[super viewDidLoad];
}
- (IBAction)hueSliderValueChanged:(id)sender {
[hueFilter setValue:[NSNumber numberWithFloat:hueSlider.value] forKey: @"inputAngle"];
[self filterImage];
}
-(void)filterImage {
adjustedImage = [CIImage imageWithCGImage:inputCGImage];
[hueFilter setValue:adjustedImage forKey:@"inputAngle"];
adjustedImage = [hueFilter outputImage];
CGImageRef cgimg = [context createCGImage:adjustedImage fromRect:[adjustedImage extent]];
adjustedUIImage = [UIImage imageWithCGImage:cgimg];
CGImageRelease(cgimg);
[imageView setImage:adjustedUIImage];
}
错误日志:
2012-08-16 17:14:02.062 HueAdjustProject [3333:707] - [CIImage doubleValue]:无法识别的选择器发送到实例0xd6606d0 2012-08-16 17:14:02.065 HueAdjustProject [3333:707] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [CIImage doubleValue]:无法识别的选择器发送到实例0xd6606d0' * 第一次抛出调用堆栈: (0x3544088f 0x377e7259 0x35443a9b 0x35442915 0x3539d650 0x36b09a3f 0xed0c5 0xed017 0x3539a3fd 0x32e8fe07 0x32e8fdc3 0x32e8fda1 0x32e8fb11 0x33085d07 0x32e8f6a5 0x32e8e8a1 0x32e8e319 0x32e74695 0x32e73f3b 0x3703322b 0x35414523 0x354144c5 0x35413313 0x353964a5 0x3539636d 0x37032439 0x32ea2cd5 0xecb17 0xecabc) 终止调用抛出异常
答案 0 :(得分:4)
[hueFilter setValue:adjustedImage forKey:@"inputAngle"];
应该是
[hueFilter setValue:adjustedImage forKey:@"inputImage"];