在iOS中的异步图像加载的UITableView的建议 [英] Suggestions on asynchronous image loading for UITableView in iOS

查看:152
本文介绍了在iOS中的异步图像加载的UITableView的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这code目前装载我表一个左路的缩略图,标题和副标题:

I am currently loading my table with a left-sided thumbnail, title and subtitle using this code:

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

    NSDictionary *post           = [posts objectAtIndex:indexPath.row];

    cell.textLabel.text       = [post objectForKey:@"post_text"];
    cell.detailTextLabel.text = [post objectForKey:@"post_author_name"];

    NSString *postpictureUrl = [post objectForKey:@"picture"];
    NSData   *data           = [NSData dataWithContentsOfURL:[NSURL URLWithString:postpictureUrl]];

    cell.imageView.image = [UIImage imageWithData:data];

    return cell;
}

当然这不会在生产中由于同步加载,我在这里做什么工作。

Of course this will not work in production due to the synchronous loading I am doing here.

什么是这样吗?

我发现 AF网络(没有用它尚未),但不知道是否有一个更轻量级的方法这个问题。

I've found AF Networking (haven't used it yet) but wonder if there's a more lightweight approach to this issue.

推荐答案

AsyncImageView 是你的朋友,检查出来的这里

AsyncImageView is your friend, check it out here.

只需设置 IMAGEURL ,你是好去。

这篇关于在iOS中的异步图像加载的UITableView的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆