ios - 可重用的 TableViewCell 加载旧图像

标签 ios objective-c uitableview

我有一个可以用搜索框搜索的动态表格 View ,如果我在背景的单元格中加载图像并且搜索文本发生变化,单元格中的对象也可能发生变化,有时是旧图像在后台加载的将完成并在不应该显示的时候显示。并非每个图像都以相同的方式加载,但这是导致问题的方法:

    [self.CarImage sd_setImageWithURL:imageURL
                                 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageurl){
                                     [self.CarImage setAlpha:0.0];
                                     [UIImageView animateWithDuration:.5 animations:^{
                                         [self.CarImage setAlpha:1.0];
                                     }];
                                 }];

任何想法将不胜感激

最佳答案

这里需要做两件事

1)在prepareforresue方法中取消当前下载请求

2) 在 prepareforresue 方法中将图像设置为 nil

希望这能解决您的问题

关于ios - 可重用的 TableViewCell 加载旧图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39538870/

相关文章:

ios - 带 SSL 固定的 AFHTTPRequestOperation 不起作用

ios - 在没有 xib 文件的情况下更改我的标签栏颜色

ios - 在 iOS 中使用核心数据时,如何为分段 TableView 构建sections数组?

ios - 如何在swiftui InsetGroupedListStyle中删除iOS 15额外的顶部填充?

ios - Firebase - 应用程序开发 - 在不产生高数据流量的情况下计算增量

objective-c - 在 UIBezierPath addLineToPoint 的末尾运行一些代码

ios - swift4 中的 UITextfield 验证 - 动态单元格

ios - GoogleMaps for iOS infoWindow 与来自实体的数据进行搜索

iOS 错误代码=-1003 "A server with the specified hostname could not be found."

iphone - 如何使 UILabel 看起来像 UITableView 中的节标题一样 eclipse 刻