Touches, Presses, and Gestures

Encapsulate your app's event-handling logic in gesture recognizers so that you can reuse that code throughout your app.


If you build your apps using standard UIKit views and controls, UIKit automatically handles touch events (including Multitouch events) for you. However, if you use custom views to display your content, you must handle all touch events that occur in your views. There are two ways to handle touch events yourself.

  • Use gesture recognizers to track the touches; see Handling UIKit Gestures.

  • Track the touches directly in your UIView subclass; see Handling Touches in Your View.


First Steps

class UIResponder

An abstract interface for responding to and handling events.

class UIEvent

An object that describes a single user interaction with your app.


class UITouch

An object representing the location, size, movement, and force of a touch occurring on the screen.

Handling Touches in Your View

Use touch events directly on a view subclass if the touch handling is intricately linked to the view visualization.

Button Presses

class UIPress

An object that represents the presence or movement of a button press on the screen for a particular event.

class UIPressesEvent

An event that describes the state of a set of physical buttons that are available to the device, such as those on an associated remote or game controller.

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.

class UITapGestureRecognizer

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

Custom Gestures

Implementing a Custom Gesture Recognizer

Discover when and how to build your own gesture recognizers

class UIGestureRecognizer

The base class for concrete gesture recognizers.

protocol UIGestureRecognizerDelegate

A set of methods implemented by the delegate of a gesture recognizer to fine-tune an app’s gesture-recognition behavior.

See Also

Event Handling

Understanding Event Handling, Responders, and the Responder Chain

Learn how events are propagated through your app and how you handle them.

Peek and Pop

Use 3D Touch input to display custom previews and actions for your content.

Keyboard and Menus

Handle keyboard input, and display a menu of custom actions.