adi*_*dit 26 iphone objective-c ipad ios
有没有一种简单的方法只在UICollectionViewFlowLayout中重新加载补充视图?我不想重装整件事.有可能这样做吗?
jhi*_*t00 26
在查看文档之后,我不确定是否重新加载单个补充视图,但您可以使用reloadSections:
更新UICollectionView中的1个或多个部分.(文档)因此,当节头需要更新时,您可以调用:
Objective-C的:
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)]];
Run Code Online (Sandbox Code Playgroud)
迅速:
self.collectionView?.reloadSections(IndexSet(0 ..< 3))
Run Code Online (Sandbox Code Playgroud)
这恰好叫:
- (UICollectionReusableView *)collectionView: (UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
//Place logic for handling update here...
}
Run Code Online (Sandbox Code Playgroud)
Owe*_*rey 12
如果要从Controller更改辅助视图的布局或大小,请使用[self.collectionView.collectionViewLayout invalidateLayout]
.如果只想刷新补充视图,请使用.[supplementaryView setNeedsDisplay]
如果补充视图很复杂和/或将更改其尺寸,请同时使用.