我正在使用SDWeb 
 Image并从新闻API中获取与新闻文章相关的图像. 
  
 
问题是,在我开始在UITableView上滚动之前,屏幕上的单元格图像没有加载.一旦我滚过一个单元格,它就会离开屏幕,一旦我回到它,最终会加载Image.
这是我的(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath代码:
if ([FeedLocal.images count] == 0) {
    [cell.imageView setimage:[UIImage imageNamed:@"e.png"]];
}
else {    
    Images *imageLocal = [FeedLocal.images objectAtIndex:0];
    Nsstring *imageURL = [Nsstring stringWithFormat:@"%@",imageLocal.url];
    NSLog(@"img url: %@",imageURL);
    // Here we use the new provided setimageWithURL: method to load the web image
    __weak UITableViewCell *wcell = cell;
    [cell.imageView setimageWithURL:[NSURL URLWithString:[Nsstring stringWithFormat:@"%@",imageURL]]
                   placeholderImage:[UIImage imageNamed:@"115_64.png"]
                          completed:^(UIImage *image,NSError *error,SDImageCacheType cacheType) {
                              if(image == nil) {
                                  [wcell.imageView setimage:[UIImage imageNamed:@"115_64.png"]];
                                   //];
                              }
                          }
    ];
} 
 知道为什么会这样吗?看起来当UITableView加载时,在滚动开始之前,图像不会被告知加载或其他东西?
任何建议都非常感谢,谢谢!
解决方法
 我之前遇到过类似的问题,结果看到tableview中的图像正确下载.您面临的真正问题是刷新问题.下载每个图像时,必须刷新它才能在tableview中显示.在我的例子中,下载部分是在一个单独的文件中完成的,所以我使用NSNotificationCenter告诉tableview控制器类刷新它.您可以使用以下代码执行以下操作: 
  
  
 
        if ([FeedLocal.images count] == 0) {
    [cell.imageView setimage:[UIImage imageNamed:@"e.png"]];
}
else {    
    Images *imageLocal = [FeedLocal.images objectAtIndex:0];
    Nsstring *imageURL = [Nsstring stringWithFormat:@"%@",SDImageCacheType cacheType) {
                              if(image == nil) {
                                  [wcell.imageView setimage:[UIImage imageNamed:@"115_64.png"]];
                                  [[NSNotificationCenter defaultCenter] postNotificationName:@"ImageDownloaded" object:nil];
                                   //];
                              }
                          }
    ];
} 
 然后你可以使用它调用重载数据,如下所示:
- (void) imageDownloaded:(NSNotification *)notification{
    [self.tableView reloadData];
} 
 这样,您无需滚动即可查看图像,而是在下载后立即显示图像.
希望这可以帮助!