UISwipeGestureRecognizer Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 3.2 and later.
Companion guide
Declared in
UISwipeGestureRecognizer.h
Related sample code

Overview

UISwipeGestureRecognizer is a concrete subclass of UIGestureRecognizer that looks for swiping gestures in one or more directions. A swipe is a discrete gesture, and thus the associated action message is sent only once per gesture.

UISwipeGestureRecognizer recognizes a swipe when the specified number of touches (numberOfTouchesRequired) have moved mostly in an allowable direction (direction) far enough to be considered a swipe. Swipes can be slow or fast. A slow swipe requires high directional precision but a small distance; a fast swipe requires low directional precision but a large distance.

You may determine the location where a swipe began by calling the UIGestureRecognizer methods locationInView: and locationOfTouch:inView:. The former method gives you the centroid if more than one touch was involved in the gesture; the latter gives the location of a particular touch.

Tasks

Configuring the Gesture

Properties

direction

The permitted direction of the swipe for this gesture recognizer.

@property(nonatomic) UISwipeGestureRecognizerDirection direction
Discussion

The default direction is UISwipeGestureRecognizerDirectionRight. See descriptions of UISwipeGestureRecognizerDirection constants for more information.

Availability
  • Available in iOS 3.2 and later.
Declared In
UISwipeGestureRecognizer.h

numberOfTouchesRequired

The number of touches that must be present for the swipe gesture to be recognized.

@property(nonatomic) NSUInteger numberOfTouchesRequired
Discussion

The default value is 1.

Availability
  • Available in iOS 3.2 and later.
Declared In
UISwipeGestureRecognizer.h

Constants

UISwipeGestureRecognizerDirection

The direction of the swipe.

typedef enum {
   UISwipeGestureRecognizerDirectionRight = 1 << 0,
   UISwipeGestureRecognizerDirectionLeft  = 1 << 1,
   UISwipeGestureRecognizerDirectionUp    = 1 << 2,
   UISwipeGestureRecognizerDirectionDown  = 1 << 3
} UISwipeGestureRecognizerDirection;
Constants
UISwipeGestureRecognizerDirectionRight

The touch or touches swipe to the right. This direction is the default.

Available in iOS 3.2 and later.

Declared in UISwipeGestureRecognizer.h.

UISwipeGestureRecognizerDirectionLeft

The touch or touches swipe to the left.

Available in iOS 3.2 and later.

Declared in UISwipeGestureRecognizer.h.

UISwipeGestureRecognizerDirectionUp

The touch or touches swipe upward.

Available in iOS 3.2 and later.

Declared in UISwipeGestureRecognizer.h.

UISwipeGestureRecognizerDirectionDown

The touch or touches swipe downward.

Available in iOS 3.2 and later.

Declared in UISwipeGestureRecognizer.h.

Availability
  • Available in iOS 3.2 and later.
Declared In
UISwipeGestureRecognizer.h