Reputation: 1910
I have a UICollectionView as the top view on my view hierarchy in IB. It's making use of a custom layout that splits the cells (registered from nibs) along the left and right edges of the view, with decoration views behind and a supplementary view the size of the entire view on top of the cells. All of that works as expected.
What doesn't work is that selecting cells is simply not being registered. They're not firing calls to collectionView: didSelectItemAtIndexPath:
(the delegate is set correctly), nor is the highlighted state of the images within the nib working. It's acting rather like a view higher up is consuming the tap, but the collectionView is the top view. I've tried removing the overlaid supplementary view and background decoration views, and also tried temporarily converting to using a flow layout in case my custom layout was doing something screwy - still nothing. Making this even more frustrating is the fact I'm using collectionViews on other view controllers in this app (governed by flow layouts), and they work perfectly fine without any special customisation. I'm out of options, any ideas?
Upvotes: 1
Views: 3205
Reputation: 1910
Problem solved. Turned out the nib I was using had a single view that was, for some reason, an instance of UICollectionReusableView
, not UICollectionViewCell
. Presumably, the reusable view class is designed to not allow selection by default.
Upvotes: 2