Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView image causes crash

I've done a million UITables - with subtitles, images, backgrounds, colors, text-styles - you name it. Suddenly, I'm crashing on this table, specifically on the line that calls for the image of the cell. Here's the code:

// Configure the cell:
cell.textLabel.font = [UIFont fontWithName:@"Franklin Gothic Book" size:18];
cell.textLabel.text = [leadershipMenu objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [leadershipSubtitlesMenu objectAtIndex:indexPath.row];

// And here's the statement that causes the crash:
cell.imageView.image = [leadershipPhotosMenu objectAtIndex:indexPath.row];

Now, the error I get is this:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[__NSCFConstantString _isResizable]: unrecognized selector sent to instance 0xcacbc'

I know for sure that the statement causing the crash is the

cell.imageView.image = ...

cause as soon as I comment it out everything works fine.

I've never in my life seen an

-[__NSCFConstantString _isResizable]: 

error. I've googled it but found very little on it.

Very peculiar.

Anyone out there got any clues?

like image 242
sirab333 Avatar asked Jun 27 '12 04:06

sirab333


2 Answers

as mentioned in your comment. the way you save your image is what causes the problem.

try this..

leadershipPhotosMenu = [[NSMutableArray alloc] initWithObjects:[UIImage imageNamed:@"JohnQ.jpg"], [UIImage imageNamed:@"BillZ.png"], nil];

the code above will store the images in your mutableArray, That will work but I suggest not to store the images in an array.

you can also solve your problem without storing your images in your array like the code above by doing:

cell.imageView.image = [UIImage imageNamed:(NSString*)[leadershipPhotosMenu objectAtIndex:indexPath.row]];

this error message means your object inside your leadershipPhotosMenu is not image, but string

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[__NSCFConstantString _isResizable]: unrecognized selector sent to instance 0xcacbc'
like image 52
janusfidel Avatar answered Nov 05 '22 01:11

janusfidel


Do this:

 cell.imageView.image = [UIImage imageNamed:[leadershipPhotosMenu objectAtIndex:indexPath.row]];
like image 1
Paresh Navadiya Avatar answered Nov 05 '22 02:11

Paresh Navadiya