afterxleep
afterxleep

Reputation: 642

UICollectionview: didSelectItemAtIndexPath does not work with single tap. Works with two fingers and swipe only

I have a simple UICollectionView with a single custom cell. Everything is working as expected, but tapping any of the items in the collection does not seem to call the didSelectItemAtIndexPath event, except when:

A. Tapping with 2 fingers on the Cell B. Swiping from either Left To Right or Right to Left

The cell contains 2 subviews, some objects on each. All are marked with "Enable User Interaction".

BTW: I made sure I'm "didSelectItemAtIndexPath" and not "didDeselect..."

I don't want to add a UITapGestureRecognizer to fix this as it seems "hacky". Any ideas?

Thanks!

Upvotes: 1

Views: 979

Answers (1)

afterxleep
afterxleep

Reputation: 642

Duh. I've just found the issue:

There was this gestureRecognizer attached to the view, which was trapping the single tap event. I attached it to the required object and it all worked!

self.view.addGestureRecognizer(UITapGestureRecognizer(target: SearchBar, action: "resignFirstResponder"))

Upvotes: 2

Related Questions