RTComponentTableView
RTComponentTableView copied to clipboard
CollectinComponent如何解决缓存?
如题! 按照示例中的代码,延时10秒后重新设置self.components;TableComponent能够很好的解决cell的缓存,而collectionComonent没有缓存;通过涂层可以看到有很多的collection叠加在一起了
- (__kindof UITableViewCell *)cellForTableView:(UITableView *)tableView atIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier forIndexPath:indexPath];
self.collectionView.frame = [self collectionViewRectForBounds:cell.bounds];
[cell.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[cell.contentView addSubview:self.collectionView];
return cell;
}
在cell的contentView中删除已有的collectionView
自定义一个 cell 子类:
@interface MyCell : UITableViewCell <UICollectionViewDatasource, UICollectionViewDelegate>
@property (strong) UICollectionView *collectionView;
@end
@implementation MyCell
- (void)prepareForReuse
{
[super prepareForReuse];
[self.collectionView reloadData];
}
@end
这些事情交给 cell 自己做,在 prepareForReuse 中