gpt4 book ai didi

ios - UITableViewCell中图片的异步加载

转载 作者:行者123 更新时间:2023-11-29 10:41:33 26 4
gpt4 key购买 nike

我想刷新已完成异步加载的单元格。

我知道有 2 种方法可以做到这一点,但没有一种是我想要的。这是我所知道的:

[myTableView reloadData];

或者

 [myTableView beginUpdates];
[myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPathOfMyCell] withRowAnimation:UITableViewRowAnimationNone];
[myTableView endUpdates];

我加载图像的异步方法是直接从我的自定义 UITableViewCell 调用的。这意味着它独立于我的 UITableView。我的最终解决方案是将我的 UITableViewCell 作为参数传递给当前单元格的索引。这看起来是一个非常丑陋的解决方案。

有人知道另一种解决方案吗?

编辑:

[myCacheClass loadUIImageFromPath:photo.mediumDistURL];

loadUIImageFromPath:(NSString *) path{
//Some code to load the image.
if(![weakSelf.delegate respondsToSelector:@selector(MyCacheDidLoadImageFromCache:)])
[weakSelf setDelegate:appDelegate.callbacksCollector];
[weakSelf.delegate MyCacheDidLoadImageFromCache:image];
}

MyCacheDidLoadImageFromCache的实现:

- (void) CacheCacheDidLoadImageFromCache: (UIImage *) image{
DDLogInfo(@"Successfully load image from cache : %@", [image description]);
myImageView.image = image;
}

最佳答案

针对此类情况,已经定义了许多更好的解决方案。您可以寻找复杂的第三方代码 AsyncImageView , AFNetworking .

关于ios - UITableViewCell中图片的异步加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24321481/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com