I can call collectionView:cellForItemAtIndexPath: to get a specific cell in order to modify that cell at any time–for instance, to update its label. I am speaking of the class instance method on UICollectionView, not the UICollectionViewDataSource method.
However, there does not appear to be a similar method for headers/footers. collectionView:viewForSupplementaryElementOfKind will return unique instances of headers/footers, instead of giving an already allocated instance. Because of this, I cannot get a pointer to a header in order to update (say) a label. I am forced to reload the section and modify it in the body of the collectionView:viewForSupplementaryElementOfKind method.
Is there a proper way to get a pointer to a specific header/footer, without resorting to a custom object cache or tags?
As far as I know there isn’t (it took until iOS 6 for there to be an equivalent call for a
UITableView,footer/headerViewForSection).If I had to guess why this isn’t possible I’d say it’s because in some layouts the
UICollectionViewwill automatically re-layout and adjust the supplementary views, so adjusting view contents ‘on the fly’ could be problematic. However, assumingUICollectionViewdoesn’t do anything funny like copying views you should probably be able to hold your supplementary views in a separate array and modify them that way – that said, no guarantees this won’t introduce some odd or strange behaviour (same for your suggestion of using tags and going into the collection view hierarchy).So the short answer is no – there isn’t a method that supports this in the API. If you had a compelling use case it’s probably worth filing a feature request through Apple’s bug reporter though.