Reputation: 55815
I have a UICollectionView
that contains a single UIButton
in each cell. I've discovered it's difficult to swipe between the horizontal pages because if you touch down on a cell to begin the swipe, the UIButton
touch events are triggered instead of allowing the swipe gesture to occur. I do have Delays Content Touches enabled for the collection view. What can I do to solve this so that it will recognize the page pan swipe gesture when you begin swiping on a cell? Perhaps the amount of delay can be increased before it recognizes a UIControl
event?
Note that I do need to preserve the touch events for the buttons - I need to know when these events occur: TouchDown, TouchDragEnter, TouchCancel, TouchDragExit, and TouchUpInside.
Upvotes: 1
Views: 1279
Reputation: 55815
It seems this was only a problem in iOS 8.0 (at least the simulator), as I'm no longer experiencing it in iOS 8.1.
Upvotes: 1
Reputation: 1993
You have to set delaysContentTouches
to YES
on your UICollectionView
. That way, there will be a small delay before the cells will receive a touch, and the built-in swipe recogniser can do its work.
You can also do that from the nib/storyboard by ticking the appropriate checkmark in IB:
Upvotes: 1
Reputation: 4218
Without the knowledge of whether you add the gesture recognizer in storyboard or by code, I can only suggest that you can try to creates a dependency relationship between the cell's gesture recognizer and the other gesture recognizer.
- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer
Upvotes: 1