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?
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'
Do this:
cell.imageView.image = [UIImage imageNamed:[leadershipPhotosMenu objectAtIndex:indexPath.row]];
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