(Created page with 'UIGestureRecognizer is an abstract class that provides an object-oriented way to add actions to different gestures. The typical code that adds a gesture recognizer is <sourc…') |
m (3.2) |
||
Line 1: | Line 1: | ||
[[UIGestureRecognizer]] is an abstract class that provides an object-oriented way to add actions to different gestures. | [[UIGestureRecognizer]] is an abstract class that provides an object-oriented way to add actions to different gestures. It becomes a documented class since firmware 3.2. | ||
The typical code that adds a gesture recognizer is | The typical code that adds a gesture recognizer is |
Revision as of 20:45, 27 January 2010
UIGestureRecognizer is an abstract class that provides an object-oriented way to add actions to different gestures. It becomes a documented class since firmware 3.2.
The typical code that adds a gesture recognizer is
UIGestureRecognizer* rec = [[UIGestureRecognizer alloc] initWithTarget:self action:@selector(touchChangedWithGestureRecognizer:)];
// set options for this recognizer.
[view addGestureRecognizer:rec];
[rec release];
Built-in Gesture Recognizers
UITapGestureRecognizer
UITapGestureRecognizer represents the gesture that p fingers tapped the screen q times consecutively.
- Input properties: numberOfTaps (q), numberOfFingers (p)
- Output properties: location, touches
UIPinchGestureRecognizer
UIPinchGestureRecognizer represents the gesture that 2 fingers moving towards or away from a center point. This gesture is usually used for scaling a view.
- Input properties: scaleThreshold
- Output properties: scale, velocity, anchorPoint, transform
scaleThreshold is the critical scale the fingers must first move apart/together before this recognizer could fire.
UILongPressGestureRecognizer
UILongPressGestureRecognizer represents the gesture that p fingers moved/stayed on the screen continuously for T seconds.
- Input properties: numberOfFingers (p), delay (T), allowableMovement
- Output properties: touches, centroid, startPoint
UIDragRecognizer
UIDragRecognizer represents the gesture that 1 or more fingers moving on the screen for a distance of d. Optionally it may also be constrained to moving only within an angle of θ ± Δθ.
- Input properties: minimumDistance (d), angle (θ), maximumDeviation (Δθ), restrictsToAngle
- Output properties: touch, startPosition, startAngle
Note that the angles are in radians.
UIPanGestureRecognizer
UIPanGestureRecognizer represents the gesture that 1 or more fingers moving on the screen for a relatively large distance. This gesture is usually used for scrolling, and is used by UIScroller and UIScrollView.
- Input properties: directionalLockEnabled
- Output properties: offset, velocity, transform
UITapAndAHalfRecognizer
UITapGestureRecognizer represents the gesture that 1 finger tapped the screen q times consecutively, and then moved/stayed on the screen.
- Input properties: numberOfFullTaps (q), allowableMovement
- Output properties: touch
UISwipeGestureRecognizer
- TODO.
Custom Gesture Recognizers
- TODO.
References