UITableView image is crashing

I made a million UITables - with subtitles, images, backgrounds, colors, text styles - you name it. Suddenly, I collapsed on this table, especially on a line that requires a cell image. Here is 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 the statement that causes the crash: cell.imageView.image = [leadershipPhotosMenu objectAtIndex:indexPath.row]; 

Now I get the following message:

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

I know for sure that the operator causing the failure is

 cell.imageView.image = ... 

call, as soon as I comment on this, everything works fine.

I've never seen in my life

 -[__NSCFConstantString _isResizable]: 

mistake. I searched for her, but found very few.

Very strange.

Does anyone have any clues?

+7
source share
3 answers

as indicated in your comment. the way you save your image is the cause of the problem.

try it.

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

the above code will save the images in your mutableArray, this will work, but I suggest not storing the images in an array.

you can also solve your problem without saving your images in your array, for example, the code above:

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

this error message means that your object inside your leadershipPhotosMenu not an image, but the line

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

Do it:

  cell.imageView.image = [UIImage imageNamed:[leadershipPhotosMenu objectAtIndex:indexPath.row]]; 
+1
source

You save the name of the image, not the image. However, ImageView has UIImage as its property, and not the name of the image. So make the following change.

 cell.imageView.image = [UIImage imageNamed:[leadershipPhotosMenu objectAtIndex:indexPath.row]]; 
+1
source

All Articles