GCD异步加载网络图片
//image
dispatch_queue_t network_queue;
network_queue = dispatch_queue_create("com.myapp.network", nil);
dispatch_async(network_queue, ^{
UIImage *cellImage = [self loadMyImageFromNetwork:[self.content objectAtIndex:indexPath.row]];
//缓存到本地
// 回到主线程
dispatch_async(dispatch_get_main_queue(), ^{
// 显示图片到界面
cell.imageView.image = cellImage;
[cell setNeedsLayout];
});
} );
demo地址:demo