Reputation: 3722
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?
Upvotes: 7
Views: 3818
Reputation: 8106
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'
Upvotes: 12
Reputation: 17186
You are storing the name of the images ad not the images. However imageView has UIImage as its property and not the image name. So make below change.
cell.imageView.image = [UIImage imageNamed:[leadershipPhotosMenu objectAtIndex:indexPath.row]];
Upvotes: 1
Reputation: 38249
Do this:
cell.imageView.image = [UIImage imageNamed:[leadershipPhotosMenu objectAtIndex:indexPath.row]];
Upvotes: 1