I have a situation where I need to have multiple recognisers for the same gesture on the same element in Swift. For context, I've written a UIView extension which adds gesture recognisers for tap and swipe gestures automatically so that occurrences can be tracked easily.
This all worked fine until it was discovered that using my extension on an element that already did something else on a tap event (navigated to a different page) caused the existing tap behaviour to no longer occur.
How can I have multiple UITapGestureRecognisers on the same element and have them all fire, rather than just the one that was added most recently?
I have tried:
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
After further research it seems that after my gesture recogniser intercepts the respective event and handles it, this event is not passed on to the UI to be handled normally. This is not due to two conflicting recognisers for the same gesture, but due to my tap recogniser not sending the event on after completion. Does anybody know how to handle a gesture in a recogniser and then pass it on down the chain? Searches and reading about the chain of responders have turned up nothing.