super: Object

This class is reserved and cannot be directly instantiated.

This is the base class for concrete gesture recognizers. A gesture-recognizer decouples the logic for recognizing a sequence of touches (or other input) and acting on that recognition. When one of these objects recognizes a common gesture or, in some cases, a change in the gesture, it sends an action event. The concrete subclasses of GestureRecognizer are the following:


  • Action() This event is called when the object recognizes its gesture or, in some cases, a change in the gesture.

  • ShouldRecognizeSimultaneously(otherGesture: UIGestureRecognizer): Bool Asks if two gesture recognizers should be allowed to recognize gestures simultaneously. This event is called when recognition of a gesture by either this gesture recognizer or the other gesture recognizer passed as the parameter 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 event may return true. The default value is false.

  • ShouldBegin(): Bool Asks if a gesture recognizer should begin interpreting touches. This method is called when a gesture recognizer attempts to transition out of the GestureRecognizerState.Possible state. Returning false causes the gesture recognizer to transition to the GestureRecognizerState.Failed state. The default value is true.

  • ShouldReceiveTouch(touch: UITouch): Bool Ask the delegate if a gesture recognizer should receive an object representing a touch. The default value is true.


  • var enabled: Bool A Boolean property that indicates whether the gesture recognizer is enabled. Disables a gesture recognizers so it does not receive touches.

  • var state: GestureRecognizerState The current state of the gesture recognizer. Some of these states are not applicable to discrete gestures. (read-only)

  • var numberOfTouches: Int Returns the number of touches involved in the gesture represented by the receiver. (read-only)

  • var view: UIView The view the gesture recognizer is attached to. (read-only)

  • var objectName: String The name of the object.


  • func locationInView(view: UIView): Point Returns a generic single-point location for the gesture, usually the centroid of the touches involved, in the coordinate system of the given view.

  • func locationOfTouch(touchIndex: Int, view: UIView): Point Returns the location of one of the gesture’s touches in the local coordinate system of a given view.

  • func requireToFail(otherGestureRecognizer: UIGestureRecognizer) This method creates a relationship with another gesture recognizer that delays the receiver’s transition out of GestureRecognizerState.Possible. The state that the receiver transitions to depends on what happens with otherGestureRecognizer: If otherGestureRecognizer transitions to UIGestureRecognizer.State.failed, the receiver transitions to its normal next state. If otherGestureRecognizer transitions to recognized or GestureRecognizerState.Began, the receiver transitions to GestureRecognizerState.Failed. An example where this method might be called is when you want a single-tap gesture require that a double-tap gesture fail.



  • .Began
  • .Cancelled
  • .Changed
  • .Ended
  • .Failed
  • .Possible