iOS Developer Library

Developer

UIKit Framework Reference UISwipeGestureRecognizer Class Reference

Options
Deployment Target:

On This Page
Language:

UISwipeGestureRecognizer

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.

Inheritance


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 3.2 and later.

Data Types

  • The direction of the swipe.

    Declaration

    Swift

    struct UISwipeGestureRecognizerDirection : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var Right: UISwipeGestureRecognizerDirection { get } static var Left: UISwipeGestureRecognizerDirection { get } static var Up: UISwipeGestureRecognizerDirection { get } static var Down: UISwipeGestureRecognizerDirection { get } }

    Objective-C

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

    Constants

    • Right

      UISwipeGestureRecognizerDirectionRight

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

      Available in iOS 3.2 and later.

    • Left

      UISwipeGestureRecognizerDirectionLeft

      The touch or touches swipe to the left.

      Available in iOS 3.2 and later.

    • Up

      UISwipeGestureRecognizerDirectionUp

      The touch or touches swipe upward.

      Available in iOS 3.2 and later.

    • Down

      UISwipeGestureRecognizerDirectionDown

      The touch or touches swipe downward.

      Available in iOS 3.2 and later.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.