Contents

canBePrevented(by:)

Overridden to indicate that the specified gesture recognizer can prevent the receiver from recognizing a gesture.

Declaration

func canBePrevented(by preventingGestureRecognizer: UIGestureRecognizer) -> Bool

Parameters

  • preventingGestureRecognizer:

    An instance of a subclass of UIGestureRecognizer.

Return Value

true to indicate that preventingGestureRecognizer can block the receiver from recognizing its gesture, otherwise false.

Discussion

Overriding these methods enables the same behavior as implementing the UIGestureRecognizerDelegate methods gestureRecognizerShouldBegin(_:) and gestureRecognizer(_:shouldReceive:). However, by overriding them, subclasses can define class-wide prevention rules. For example, a UITapGestureRecognizer object never prevents another UITapGestureRecognizer object with a higher tap count.

See Also

Implementing subclasses