Class

UITapGestureRecognizer

A concrete subclass of UIGestureRecognizer that looks for single or multiple taps.

Overview

For the gesture to be recognized, the specified number of fingers must tap the view a specified number of times. Although taps are discrete gestures, they are discrete for each state of the gesture recognizer; thus the associated action message is sent when the gesture begins and is sent for each intermediate state until (and including) the ending state of the gesture. Code that handles tap gestures should therefore test for the state of the gesture, for example:

func handleTap(sender: UITapGestureRecognizer) {
    if sender.state == .Ended {
        // handling code
    }
}

Action methods handling this gesture may get the location of the gesture as a whole by calling the UIGestureRecognizer method location(in:); if there are multiple taps, this location is the first tap; if there are multiple touches, this location is the centroid of all fingers tapping the view. Clients may get the location of particular touches in the tap by calling location(ofTouch:in:); if multiple taps are allowed, this location is that of the first tap.

Topics

Configuring the Gesture

var numberOfTapsRequired: Int

The number of taps for the gesture to be recognized.

var numberOfTouchesRequired: Int

The number of fingers required to tap for the gesture to be recognized.

Relationships

Inherits From

Conforms To

See Also

UIKit Gestures

Handling UIKit Gestures

Use gesture recognizers to simplify touch handling and create a consistent user experience.

Coordinating Multiple Gesture Recognizers

Discover how to use multiple gesture recognizers on the same view.

class UILongPressGestureRecognizer

A concrete subclass of UIGestureRecognizer that looks for long-press gestures.

class UIPanGestureRecognizer

A concrete subclass of UIGestureRecognizer that looks for panning (dragging) gestures.

class UIPinchGestureRecognizer

A concrete subclass of UIGestureRecognizer that looks for pinching gestures involving two touches.

class UIScreenEdgePanGestureRecognizer

A gesture recognizer that looks for panning (dragging) gestures that start near an edge of the screen.

class UISwipeGestureRecognizer

A concrete subclass of UIGestureRecognizer that looks for swiping gestures in one or more directions.

class UIRotationGestureRecognizer

A concrete subclass of UIGestureRecognizer that looks for rotation gestures involving two touches.