如何在collectionView中重新加载补充视图 [英] how to reload supplementary view in collectionView
本文介绍了如何在collectionView中重新加载补充视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种简单的方法只能在UICollectionViewFlowLayout中重新加载补充视图?我不想重装整件事。是否可以这样做?
Is there an easy way to reload the suppplementary view only in a UICollectionViewFlowLayout? I don't want to reload the whole thing. Is it possible to do so?
推荐答案
在查看文档后,我不确定是否重新加载了单独的补充视图,但是您可以使用 reloadSections:
来更新UICollectionView中的1个或多个部分。 (文档)所以当节头需要更新时,你可以打电话:
After reviewing the documentation, I'm not sure about reloading an individual supplementary view, but you can use reloadSections:
to update 1 or more sections in the UICollectionView. (documentation) So when a section header needs updating, you can call:
Objective-C:
Objective-C:
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)]];
Swift:
self.collectionView?.reloadSections(IndexSet(0 ..< 3))
碰巧会发生这种情况:
- (UICollectionReusableView *)collectionView: (UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
//Place logic for handling update here...
}
这篇关于如何在collectionView中重新加载补充视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文