user1926467
user1926467

Reputation: 3

UIImage unrecognized selector sent to instance

I have the 'classic' error:

unrecognized selector sent to instance.

If I read through other comparable questions it should be memory related, however I can't find out what I'm doing wrong.

Here is what I try to do:

I use the brilliant code of Trevor

This is my code:

The roundedCornerImage:borderSize: is giving the trouble

NSInteger my_borderSize = 0.1;
UIImage *Image_large = [image_sel croppedImage:CGRectMake((my_width/2) -(my_height*0.66)/2, 0, my_height*0.66, my_height) ];
UIImage *roundedCornerImage_temp = [Image_large roundedCornerImage:0.8 borderSize:my_borderSize];

Upvotes: 0

Views: 1411

Answers (1)

Nate
Nate

Reputation: 31045

That method is not in Apple's UIImage class. They are extensions to UIImage written by the guy whose code you link to.

You need to make sure to add UIImage+RoundedCorner.h and UIImage+RoundedCorner.m to your Xcode project, and then in the class where you want to use roundedCornerImage:borderSize:, you should

#import "UIImage+RoundedCorner.h"

Also, I notice that you're passing in decimal values for both cornerSize and borderSize. Those are supposed to be NSInteger values, per Trevor's API. I would guess that those are in display points, but apparently, he limited it to integer values.

Update: also make sure that the UIImage+RoundedCorner.m file is listed among your Compile Sources:

enter image description here

Upvotes: 1

Related Questions