我想用 5 个不同的图像视图填充我的自定义表格视图单元格。在我的 customTableViewCell 中,我这样做了。
-(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;
}
}
在我的 CellForRowAtIndexPath 中,我这样做了。
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;
目前我的 tableview 看起来像这样。
|---------------------------------------------------------------------|
| |
| 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 |
|---------------------------------------------------------------------|
我希望你能看到问题所在。我认为在设置图像之后它应该转到下一个 indexPath。我的问题是现在我该怎么做?
亲切的问候。