ios - 在collectionView中加载图像

标签 ios objective-c uitableview asynchronous uicollectionview

每个 UITableViewCell 都包含一个 UICollectionView。无法弄清楚为什么某些 UICollectionViewCell 图像没有显示。我正在使用 SDWebImage 库来加载图像。方法 - (void)sd_setImageWithURL:(NSURL *)url 调用 [self sd_cancelCurrentImageLoad];。我认为取消先前的请求是问题所在,但请阅读会产生竞争条件的地方。并非每个 UITableViewCell 都会出现问题,如果我点击单元格以获取详细信息并返回,则会填充图像。也许我需要在某处重新加载数据。关于如何解决此问题的任何提示?
enter image description here

最佳答案

如果您尝试从服务器获取图像来尝试此操作。

#import "UIImageView+WebCache.h"

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NewProfileCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];


[cell.img_user_image sd_setImageWithURL:[NSURL URLWithString:[mutDict valueForKey:@"UserImageURL"][indexPath.row]] placeholderImage:[UIImage imageNamed:@"No_IMAGE_PLACE"]];

return cell;
}

关于ios - 在collectionView中加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49637929/

相关文章:

iOS8 - 在 UINavigationController 上推送 UIViewController 并旋转设备后,以前的 View Controller 中的大小错误

ios - echarts(iOS图表)未显示在自定义uitableviewcell中

iphone - 将 UIImage 添加到 UITableViewCell "State Touched"

ios - 如何有效管理大量的iOS应用内购买?

ios - “@property(非原子,强)”和“@property”之间的区别

ios - 获取 User-Agent 字符串的 AppleWebKit/Mobile/Safari 版本号的更好方法?

ios - XCTest 如何执行呈现模态视图的 segue 并测试 presentedViewController

iPhone 核心数据 - 获取的托管对象未在设备上发布(在模拟器上很好)

objective-c - 预处理器指令可以用于为 Mac 和 iOS 导入不同的头文件吗?

iphone - 在 UITableView 中缓存图像