【问题标题】:Images appear after scrolling table view (AFNetworking)滚动表格视图后出现图像 (AFNetworking)
【发布时间】:2013-05-14 08:57:51
【问题描述】:

我正在使用 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;
}

【问题讨论】:

标签: iphone ios objective-c networking afnetworking


【解决方案1】:

试试这个

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2019-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-13
      • 1970-01-01
      • 2013-04-26
      • 1970-01-01
      相关资源
      最近更新 更多