akaru akaru - 1 year ago 99
iOS Question

How to get the index path of a UICollectionView header?

Using the view's indexPathForItemAtPoint, I will get an index path for a cell, but never a UICollectionReusableView (header/footer) -- as it always returns nil.

Answer Source

You should make your own dictionary mapping index paths to header views. In your collectionView:viewForSupplementaryElementOfKind:atIndexPath: method, put the view into the dictionary before returning it. In your collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath:, remove the view from the dictionary.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download