adit adit - 11 months ago 1010
iOS Question

how to reload supplementary view in collectionView

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?


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:

[self.collectionView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)]];

Which happens to call:

- (UICollectionReusableView *)collectionView: (UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {

       //Place logic for handling update here...