I'm making an UITableView with an UIIMage per cell.
To set a different Image per cell I loaded all images in project and made an array with all images _flagsArray = [NSArray arrayWithObjects: @"flag_Italia.png", @"flag_USA", nil];
.
In cellForRowAtIndexPath
I wrote
UIImageView * flagImageView = (UIImageView *) [self.view viewWithTag:1]; //declaration of UIImageView in cell
UIImage * flagImage = (UIImage *)[_flagsArray objectAtIndex:indexPath.row]; //read UImage
[flagImageView setImage : flagImage]; //should assign UImage to UIImageView
Running it crash with log *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString size]: unrecognized selector sent to instance 0xcbdc'
, with signal SIGABRT on third row but I can't understand why, what's wrong?
Thank you!
Your array contains strings not images. Also, it looks like you're trying to get the image view from
self.view
when you should getting it from thecell
. Do like this:Or more succinctly: