Objective c 带有tableCell索引的Objective C imageView

Objective c 带有tableCell索引的Objective C imageView,objective-c,uiimage,imageview,cell,Objective C,Uiimage,Imageview,Cell,我想将第一个图像添加到第一个单元格中 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; static NSDateFormatter *formatter = nil; if (formatter == nil)

我想将第一个图像添加到第一个单元格中

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    static NSDateFormatter *formatter = nil;
    if (formatter == nil) {
        formatter = [[NSDateFormatter alloc] init];
        [formatter setDateStyle:NSDateFormatterMediumStyle];
    }
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    MovieSighting *sightingAtIndex = [self.dataController objectInListAtIndex:indexPath.row];
    [[cell textLabel] setText:sightingAtIndex.titulo];
    [[cell detailTextLabel] setText:[NSString stringWithFormat:@"%lu",(unsigned long)sightingAtIndex.anyo]];

    [[cell imageView] setImage:[UIImage imageNamed:@"Batman.jpg"] ];
    [[cell imageView] setImage:[UIImage imageNamed:@"300.jpg"]];


    //cell.imageView.image = [UIImage imageNamed:@"Batman.jpg"];
    //cell.imageView.image = [UIImage imageNamed:@"300.jpg"];

    //[[cell detailTextLabel] setText:[formatter stringFromDate:(NSDate *)sightingAtIndex.date]];
    return cell;
}
我想将第二个图像添加到第二个单元格中

cell.imageView.image = [UIImage imageNamed:@"Batman.jpg"];

我应该使用atIndex吗?

只需检查索引即可知道您所在的单元格:

cell.imageView.image = [UIImage imageNamed:@"300.jpg"];

该方法将对每个要显示的单元格调用一次,而不是对所有单元格调用一次。

只需检查索引即可知道您所在的单元格:

cell.imageView.image = [UIImage imageNamed:@"300.jpg"];
该方法对于要显示的每个单元格调用一次,而不是对所有单元格调用一次