I want to fill up my custom tableview cells with 5 different imageviews.
In my customTableViewCell I do this.
-(void)setImage:(UIImage *)image forPosition:(NSUInteger)position{
if(position == 1){
_img_Player1.image = image;
}else if(position == 2){
_img_Player2.image = image;
}else if(position == 3){
_img_Player3.image = image;
}else if(position == 4){
_img_Player4.image = image;
}else if(position == 5){
_img_Player5.image = image;
}else if(position == 6){
_img_Player6.image = image;
}
}
And in my CellForRowAtIndexPath I do this.
static NSString *simpleTableIdentifier = @"PlayerCustomCell";
PlayerCustomCell *cell = (PlayerCustomCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"PlayerCustomCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
Team *team = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:team.image]];
UIImage* image = [[UIImage alloc] initWithData:imageData];
for(int i=0;i<=5;i++)
{
[cell setImage:image forPosition:i];
}
return cell;
At the moment my tableview looks like this.
|---------------------------------------------------------------------|
| |
| bird image bird image bird image bird image bird image |
|---------------------------------------------------------------------|
| |
| dog image dog image dog image dog image dog image |
|---------------------------------------------------------------------|
| |
| cat image cat image cat image cat image cat image |
|---------------------------------------------------------------------|
I hope you see what the problem is. I think that after it sets the image it should go to the next indexPath. My question is now how can I do this ?
kind regards.
Firstly add 5 NSData like this in .h file
In CellForRowAtIndexPath do this: