UITapGestureRecognizer
A discrete gesture recognizer that interprets single or multiple taps.
Declaration
@MainActor class UITapGestureRecognizerMentioned in
Overview
UITapGestureRecognizer is a concrete subclass of UIGestureRecognizer.
For gesture recognition, the specified number of fingers must tap the view a specified number of times. Although taps are discrete gestures, they’re discrete for each state of the gesture recognizer. The system sends the associated action message when the gesture begins and then again for each intermediate state until (and including) the ending state of the gesture. Code that handles tap gestures should test for the state of the gesture, for example:
Action methods handling this gesture can 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 can get the location of particular touches in the tap by calling location(ofTouch:in:). If multiple taps are allowed, this location is the first tap.
Topics
Configuring the gesture
See Also
Standard gestures
Handling UIKit gesturesCoordinating multiple gesture recognizersAdopting hover support for Apple PencilSupporting gesture interaction in your appsUIHoverGestureRecognizerUILongPressGestureRecognizerUIPanGestureRecognizerUIPinchGestureRecognizerUIRotationGestureRecognizerUIScreenEdgePanGestureRecognizerUISwipeGestureRecognizer