I was using CI filters and getting strange error, how can i know what i am missing by looking in to log
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)
How To Fix Unrecognized Selector Sent To Instance Error When Click Button. 1 Click Show the Project navigat ... 2 Click Main. ... 3 Select the ui button component ... 4 Then click View —> Inspectors ... 5 This will open the connections ... 6 Now rebuild your Xcode project ... 7 But if you find above method d ...
Since the selector is another name for the method, the error is basically saying that it doesn’t recognize the function that you’re trying to call on this object. The error also gives us the information that we are trying to call the set image method of an object that is a UIButton.
You can see there are two functions that have been connected to the Sent Events —> Touch Up Inside event. You should click the close button on the unused function left side to remove the connection.
It looks like you're not memory managing the view controller properly and it is being deallocated at some point - which causes the numberButtonClicked: method to be sent to another object that is now occupying the memory that the view controller was previously occupying... Make sure you're properly retaining/releasing your view controller.
This exception would happen if the object you set as "inputImage"
is a UIImage
. According to the documentation the inputImage object has to be a CIImage
.
Try to get the CIImage from you UIImage first.
[filter setValue:image.CIImage forKey:@"inputImage"];
^^^^^^^
After Matthia's help finally able to solve it. Correct code is..
CIFilter *filter = [CIFilter filterWithName:@"CIFalseColor"];
CIImage * beginImage = [CIImage imageWithCGImage:image.CGImage];
// set value must be of ciimage not uiimage
[filter setValue:beginImage 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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With