1

我有一个 TableViewController。我正在使用自定义单元格。单元格有 2 个标签和 imageView。

我想通过 SDWebImage 异步加载图像。

代码是:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"NewsCell";
    NewsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    if (cell == nil)
    {
        cell = [[NewsCell alloc] initWithStyle:UITableViewCellStyleDefault
                                   reuseIdentifier:CellIdentifier];
    }
    News* new = [_news objectAtIndex:indexPath.row];
    cell.titleLabel.text = new.title;
    cell.contentLabel.text = new.content;
    if(new.images.count > 0){
        [cell.imageView setImageWithURL:[Helper pathForBigImage:new.images[0]]];
    }

    return cell;
}

第一次加载时看不到图像。如果我重新加载,我可以看到它。

我哪里错了?

4

0 回答 0