Domanda

I need to know if the UICollectionView header supplementary view is currently in view in order to force it to refresh/update when an app setting/preference is changed.

If the header is not in view, once scrolled to, the header will get drawn appropriately but right now that only happens on load and if the user scrolls off the header then back.

If the header is in view, I need it to update but I don't really want to have to reload the entire 0th section every time this setting changes (just when the header is in view...).

È stato utile?

Soluzione

You could do something like keep a property around when the view gets dequeued. Then change it when it disappears using:

- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingSupplementaryView:(UICollectionReusableView *)view forElementOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath;

Depending on how you want your update to occur you could either keep a bool isVisible around or start an NSTimer when it appears and stop the timer when it disappears.

Unfortunately it doesn't look like there's a visibleSupplementaryViews method.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top