UIPanGestureRecognizer Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 3.2 and later. |
| Companion guide | |
| Declared in | UIPanGestureRecognizer.h |
Overview
UIPanGestureRecognizer is a concrete subclass of UIGestureRecognizer 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 (UIGestureRecognizerStateBegan) when the minimum number of fingers allowed (minimumNumberOfTouches) has moved enough to be considered a pan. It changes (UIGestureRecognizerStateChanged) when a finger moves while at least the minimum number of fingers are pressed down. It ends (UIGestureRecognizerStateEnded) when all fingers are lifted.
Clients of this class can, in their action methods, query the UIPanGestureRecognizer object for the current translation of the gesture (translationInView:) and the velocity of the translation (velocityInView:). They can specify the view whose coordinate system should be used for the translation and velocity values. Clients may also reset the translation to a desired value.
Tasks
Configuring the Gesture Recognizer
-
maximumNumberOfTouchesproperty -
minimumNumberOfTouchesproperty
Tracking the Location and Velocity of the Gesture
Properties
maximumNumberOfTouches
The maximum number of fingers that can be touching the view for this gesture to be recognized.
Discussion
The default value is NSUIntegerMax.
Availability
- Available in iOS 3.2 and later.
Declared In
UIPanGestureRecognizer.hminimumNumberOfTouches
The minimum number of fingers that can be touching the view for this gesture to be recognized.
Discussion
The default value is 1.
Availability
- Available in iOS 3.2 and later.
Declared In
UIPanGestureRecognizer.hInstance Methods
setTranslation:inView:
Sets the translation value in the coordinate system of the specified view.
Parameters
- translation
A point that identifies the new translation value.
- view
A view in whose coordinate system the translation is to occur.
Discussion
Changing the translation value resets the velocity of the pan.
Availability
- Available in iOS 3.2 and later.
See Also
Declared In
UIPanGestureRecognizer.htranslationInView:
The translation of the pan gesture in the coordinate system of the specified view.
Parameters
- view
The view in whose coordinate system the translation of the pan gesture should be computed. If you want to adjust a view's location to keep it under the user's finger, request the translation in that view's superview's coordinate system.
Return Value
A point identifying the new location of a view in the coordinate system of its designated superview.
Discussion
The x and y values report the total translation over time. They are not delta values from the last time that the translation was reported. Apply the translation value to the state of the view when the gesture is first recognized—do not concatenate the value each time the handler is called.
Availability
- Available in iOS 3.2 and later.
See Also
Declared In
UIPanGestureRecognizer.hvelocityInView:
The velocity of the pan gesture in the coordinate system of the specified view.
Parameters
- view
The view in whose coordinate system the velocity of the pan gesture is computed.
Return Value
The velocity of the pan gesture, which is expressed in points per second. The velocity is broken into horizontal and vertical components.
Availability
- Available in iOS 3.2 and later.
See Also
Declared In
UIPanGestureRecognizer.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)