OGeek|极客世界-中国程序员成长平台

标题: ios - 将多个图像异步加载到单个单元格 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 13:35
标题: ios - 将多个图像异步加载到单个单元格

我在向 TableView 的每个单元格加载 5 张图像时遇到问题。我使用 AFNetworking 进行下载,使用 setImageWithUrl 方法进行 imageView:

for (int i = 0; i < urls.count; i++) {
    [self.photoImageView[i] setImageWithURL:urls[i]];
}

TableView 滚动时非常刹车。但是当我尝试加载 1 或 2 滚动时没有刹车。 enter image description here 如何在不刹车的情况下修正下载图片?



Best Answer-推荐答案


我认为下面的代码对你有帮助。

你第一次使用这个库 SDWebImage 然后实现下面的代码。

#import <SDWebImage/UIImageView+WebCache.h>
...
[cell.imageView sd_setImageWithURL:[NSURL URLWithString"URL"]
             placeholderImage:[UIImage imageNamed"placeholder.png"]];

关于ios - 将多个图像异步加载到单个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44962324/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4