我在 UITableViewCell 中有一个 UICollectionView, Collection View 的图像正在从后台线程的解析中检索。我遇到的问题是我无法调用 Collection View reloadData,因为我无法设置 UICollectionView 的属性,因为它位于 TableView 单元格内。关于如何在之后重新加载 Collection View 数据的任何想法后台线程已完成查询?
最佳答案
子类化 UITableViewCell 并添加方法和对其 Collection View 的引用。在那里处理您的电话。我假设您将 Collection View 设为 TableView Controller 上的一个属性
例如
CollectionViewTableCell.h:
@interface CollectionViewTableCell : UITableViewCell
@end
CollectionViewTableCell.m:
@interface CollectionViewTableCell ()
@property (nonatomic, weak) @IBOutlet UICollectionView* collectionView;
@end
@implementation CollectionViewTableCell
-(void) awakeFromNib {
[self loadData];
}
-(void) loadData {
// load parse data asynchronously and then call reloadData on your collection view
}
// make sure to implement delegate/datasource methods for your collection view
@end
请注意,有一些方法可以将图像 url 发送到 UIImageView,图像将从 url 异步加载(例如 AFNetworking 有一个支持此功能的类别)。
关于ios - tableview 单元格中的 Collection View 重新加载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30677635/