簡體   English   中英

如何在collectionView中重新加載補充視圖

[英]how to reload supplementary view in collectionView

是否有一種簡單的方法可以僅在UICollectionViewFlowLayout中重新加載補充視圖? 我不想重裝整個東西。 有可能這樣做嗎?

閱讀文檔后,我不確定是否要重新加載單個補充視圖,但是可以使用reloadSections:更新reloadSections: 1個或多個部分。 文檔 )因此,當節標題需要更新時,可以調用:

目標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]如果補充視圖為復雜和/或將更改其尺寸。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM