如何重新加载collectionView中的补充视图
有没有一种简单的方法来重新加载只在UICollectionViewFlowLayout suppplementary视图? 我不想重新加载整个事情。 有可能吗?
在查看文档之后,我不确定是否要重新加载单独的补充视图,但是您可以使用reloadSections:
更新reloadSections:
一个或多个部分。 ( 文档 )所以当一个部分头需要更新时,你可以调用:
Objective-C的:
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)]];
迅速:
self.collectionView?.reloadSections(IndexSet(0 ..< 3))
碰巧发生什么情况:
- (UICollectionReusableView *)collectionView: (UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { //Place logic for handling update here... }
如果要从Controller中更改补充视图的布局或大小,请使用[self.collectionView.collectionViewLayout invalidateLayout]
。如果只想刷新补充视图,请使用[supplementaryView setNeedsDisplay]
View [supplementaryView setNeedsDisplay]
如果补充视图是复杂和/或将改变其尺寸。