Asks the delegate if two gesture recognizers should be allowed to recognize gestures simultaneously.
SDKs
- iOS 3.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
optional func gestureRecognizer(_ gestureRecognizer: UIGesture Recognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGesture Recognizer) -> Bool
Parameters
gestureRecognizer
An instance of a subclass of the abstract base class
UIGesture
. This is the object sending the message to the delegate.Recognizer otherGestureRecognizer
An instance of a subclass of the abstract base class
UIGesture
.Recognizer
Return Value
true
to allow both gesture
and other
to recognize their gestures simultaneously. The default implementation returns false
—no two gestures can be recognized simultaneously.
Discussion
This method is called when recognition of a gesture by either gesture
or other
would block the other gesture recognizer from recognizing its gesture. Note that returning true
is guaranteed to allow simultaneous recognition; returning false
, on the other hand, is not guaranteed to prevent simultaneous recognition because the other gesture recognizer's delegate may return true
.