0

我正在使用 AFNetworking 从服务器下载图像,一切正常,但除非我滚动表格视图,否则图像不会出现。这是我的代码:

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

}

//configuring news feed
    dictionary = [newsFeed objectAtIndex:indexPath.row];
 //display thumbnails


    UIImageView *image = [[UIImageView alloc]init];
    [image setImageWithURL:[NSURL URLWithString:[dictionary objectForKey:@"image"]]placeholderImage:[UIImage imageNamed:NEWSAVATAR]];
    cell.imageView.image = [image.image imageScaledToSize:CGSizeMake(55, 55)];
    [cell setNeedsLayout];


    return cell;
}
4

2 回答 2

1

试试这个

[ cell.imageView.image  setImageWithURL:[NSURL URLWithString:[dictionary objectForKey:@"image"]]placeholderImage:[UIImage imageNamed:NEWSAVATAR]];
于 2013-05-14T09:26:46.013 回答
0

仅当该单元格可见时才调用此委托方法,即您已滚动到该单元格。如果您不希望这种情况发生,您必须调用网络服务并将所有图像保存在本地,然后从本地文件夹中选择它。

于 2013-05-14T09:58:35.960 回答