iphone - 滚动表格 View 后出现图像 (AFNetworking)

标签 iphone ios objective-c networking afnetworking

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

   - (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;
}

最佳答案

试试这个

[ cell.imageView.image  setImageWithURL:[NSURL URLWithString:[dictionary objectForKey:@"image"]]placeholderImage:[UIImage imageNamed:NEWSAVATAR]];

关于iphone - 滚动表格 View 后出现图像 (AFNetworking),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16538930/

相关文章:

iphone - 具有时间延迟的 performSelector 在 for 循环中不起作用 - iPhone

iphone - 按照教程中的说明调用FBSession.activeSession会导致NSException

ios - 单击 UITableViewCell 上的 UIImageView 模板图像色调颜色更改

objective-c - 测试自己的 OS X 框架

ios - SpriteKit - Edge 的行为不符合预期

ios - 使用 ARC 将 NSArray 转换为 C 数组

ios - 授权推特成功后返回应用

iphone - 发件人标签总是返回 1

iphone xcode 默认横向模式

iphone - 在 iPhone 中下载图像时在 UIProgressView 中显示准确的进度