【发布时间】:2016-04-21 11:53:29
【问题描述】:
我需要在每个 UITableViewCell 中显示多个图像。为此,我使用 SDWebImage 异步下载图像。我在 UITableViewCell 的 configCell 方法中运行以下代码:
for (int i=0; i<allOrganizationIds.count; i++) {
self.orgView = [[UIImageView alloc] initWithFrame:CGRectMake((self.frame.size.width - 10) - (55 * position), 3, 50, 15)];
org = [[DLOrganizationManager getInstance] organizationForId:[allOrganizationIds[i] intValue]];
[self.orgView sd_setImageWithURL:[NSURL URLWithString:org.organizationLogoUrl] placeholderImage:[UIImage imageNamed:@"category-selected"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[self addSubview:self.orgView];
}];
}
问题是每个单元格只显示一个图像,即使应该有三个。 complete 块只执行一次。当将特定单元格滚动出视图并返回时,所有图像都是可见的。
为什么每次成功下载图像时 UIImageView 都不会更新,即使单元格仍然可见?
【问题讨论】:
标签: ios objective-c uitableview uiimageview sdwebimage