PanGesture


super: UIPanGestureRecognizer on iOS

PanGesture is a concrete gesture recognizer that looks for panning (dragging) gestures. The user must be pressing one or more fingers on a view while they pan it. Clients implementing the action method for this gesture recognizer can ask it for the current translation and velocity of the gesture. A panning gesture is continuous. It begins (GestureRecognizerState.Began) when the minimum number of fingers allowed (minimumNumberOfTouches) has moved enough to be considered a pan. It changes (GestureRecognizerState.Changed) when a finger moves while at least the minimum number of fingers are pressed down. It ends (GestureRecognizerState.Ended) when all fingers are lifted.

Events

  • Load() This event is called when the object becames available in the current runtime system.

  • 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.

  • Unload() This event is called when the object has been removed from the current runtime system (but not yet deallocated).

Properties

  • var maximumNumberOfTouches: Int The maximum number of fingers that can be touching the view for this gesture to be recognized.

  • var minimumNumberOfTouches: Int The minimum number of fingers that can be touching the view for this gesture to be recognized. The default value is 1.

Methods

  • func translationInView(view: Object): Point The translation of the pan gesture in the coordinate system of the specified view. The x and y values report the total translation over time.

  • func setTranslationInView(translation: Point, view: Object): Point Sets the translation value in the coordinate system of the specified view. Changing the translation value resets the velocity of the pan.

  • func velocityInView(view: Object): Point The velocity of the pan gesture, expressed in points per second, in the coordinate system of the specified view. The velocity is broken into horizontal and vertical components.