<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIResponder",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIResponder"
  },
  "title" : "UIResponder"
}
-->

# UIResponder

An abstract interface for responding to and handling events.

```
@MainActor class UIResponder
```

## Overview

Responder objects — instances of [`UIResponder`](/documentation/UIKit/UIResponder) — constitute the event-handling backbone of a UIKit app. Many key objects are also responders, including the [`UIApplication`](/documentation/UIKit/UIApplication) object, [`UIViewController`](/documentation/UIKit/UIViewController) objects, and all [`UIView`](/documentation/UIKit/UIView) objects (which includes [`UIWindow`](/documentation/UIKit/UIWindow)). As events occur, UIKit dispatches them to your app’s responder objects for handling.

There are several kinds of events, including touch events, motion events, remote-control events, and press events. To handle a specific type of event, a responder must override the corresponding methods. For example, to handle touch events, a responder implements the [`touchesBegan(_:with:)`](/documentation/UIKit/UIResponder/touchesBegan(_:with:)), [`touchesMoved(_:with:)`](/documentation/UIKit/UIResponder/touchesMoved(_:with:)), [`touchesEnded(_:with:)`](/documentation/UIKit/UIResponder/touchesEnded(_:with:)), and [`touchesCancelled(_:with:)`](/documentation/UIKit/UIResponder/touchesCancelled(_:with:)) methods. In the case of touches, the responder uses the event information provided by UIKit to track changes to those touches and to update the app’s interface appropriately.

In addition to handling events, UIKit responders also manage the forwarding of unhandled events to other parts of your app. If a given responder doesn’t handle an event, it forwards that event to the next event in the responder chain. UIKit manages the responder chain dynamically, using predefined rules to determine which object should be next to receive an event. For example, a view forwards events to its superview, and the root view of a hierarchy forwards events to its view controller.

Responders process [`UIEvent`](/documentation/UIKit/UIEvent) objects but can also accept custom input through an input view. The system’s keyboard is the most obvious example of an input view. When the user taps a [`UITextField`](/documentation/UIKit/UITextField) and [`UITextView`](/documentation/UIKit/UITextView) object onscreen, the view becomes the first responder and displays its input view, which is the system keyboard. Similarly, you can create custom input views and display them when other responders become active. To associate a custom input view with a responder, assign that view to the [`inputView`](/documentation/UIKit/UIResponder/inputView) property of the responder.

For information about responders and the responder chain, see [Using responders and the responder chain to handle events](/documentation/UIKit/using-responders-and-the-responder-chain-to-handle-events).

## Topics

### Managing the responder chain

[`next`](/documentation/UIKit/UIResponder/next)

Returns the next responder in the responder chain, or `nil` if there’s no next responder.

[`isFirstResponder`](/documentation/UIKit/UIResponder/isFirstResponder)

Returns a Boolean value indicating whether this object is the first responder.

[`canBecomeFirstResponder`](/documentation/UIKit/UIResponder/canBecomeFirstResponder)

Returns a Boolean value indicating whether this object can become the first responder.

[`becomeFirstResponder()`](/documentation/UIKit/UIResponder/becomeFirstResponder())

Asks UIKit to make this object the first responder in its window.

[`canResignFirstResponder`](/documentation/UIKit/UIResponder/canResignFirstResponder)

Returns a Boolean value indicating whether the responder is willing to relinquish first-responder status.

[`resignFirstResponder()`](/documentation/UIKit/UIResponder/resignFirstResponder())

Notifies this object that it has been asked to relinquish its status as first responder in its window.

### Responding to touch events

[`touchesBegan(_:with:)`](/documentation/UIKit/UIResponder/touchesBegan(_:with:))

Tells this object that one or more new touches occurred in a view or window.

[`touchesMoved(_:with:)`](/documentation/UIKit/UIResponder/touchesMoved(_:with:))

Tells the responder when one or more touches associated with an event changed.

[`touchesEnded(_:with:)`](/documentation/UIKit/UIResponder/touchesEnded(_:with:))

Tells the responder when one or more fingers are raised from a view or window.

[`touchesCancelled(_:with:)`](/documentation/UIKit/UIResponder/touchesCancelled(_:with:))

Tells the responder when a system event (such as a system alert) cancels a touch sequence.

[`touchesEstimatedPropertiesUpdated(_:)`](/documentation/UIKit/UIResponder/touchesEstimatedPropertiesUpdated(_:))

Tells the responder that updated values were received for previously estimated properties or that an update is no longer expected.

### Responding to motion events

[`motionBegan(_:with:)`](/documentation/UIKit/UIResponder/motionBegan(_:with:))

Tells the responder that a motion event has begun.

[`motionEnded(_:with:)`](/documentation/UIKit/UIResponder/motionEnded(_:with:))

Tells the responder that a motion event has ended.

[`motionCancelled(_:with:)`](/documentation/UIKit/UIResponder/motionCancelled(_:with:))

Tells the responder that a motion event has been canceled.

### Responding to press events

Generally, responders that handle press events should override all four of these methods.

[`pressesBegan(_:with:)`](/documentation/UIKit/UIResponder/pressesBegan(_:with:))

Tells this object when a physical button is first pressed.

[`pressesChanged(_:with:)`](/documentation/UIKit/UIResponder/pressesChanged(_:with:))

Tells this object when a value associated with a press has changed.

[`pressesEnded(_:with:)`](/documentation/UIKit/UIResponder/pressesEnded(_:with:))

Tells the object when a button is released.

[`pressesCancelled(_:with:)`](/documentation/UIKit/UIResponder/pressesCancelled(_:with:))

Tells this object when a system event (such as a low-memory warning) cancels a press event.

### Responding to remote-control events

[`remoteControlReceived(with:)`](/documentation/UIKit/UIResponder/remoteControlReceived(with:))

Tells the object when a remote-control event is received.

### Managing input views

[`inputView`](/documentation/UIKit/UIResponder/inputView)

The custom input view to display when the responder becomes the first responder.

[`inputViewController`](/documentation/UIKit/UIResponder/inputViewController)

The custom input view controller to use when the responder becomes the first responder.

[`inputAccessoryView`](/documentation/UIKit/UIResponder/inputAccessoryView)

The custom input accessory view to display when the responder becomes the first responder.

[`inputAccessoryViewController`](/documentation/UIKit/UIResponder/inputAccessoryViewController)

The custom input accessory view controller to display when the responder becomes the first responder.

[`reloadInputViews()`](/documentation/UIKit/UIResponder/reloadInputViews())

Updates the custom input and accessory views when the object is the first responder.

### Getting the undo manager

[`undoManager`](/documentation/UIKit/UIResponder/undoManager)

Returns the nearest shared undo manager in the responder chain.

### Building and validating commands

[`buildMenu(with:)`](/documentation/UIKit/UIResponder/buildMenu(with:))

Asks the receiving responder to add and remove items from a menu system.

[`validate(_:)`](/documentation/UIKit/UIResponder/validate(_:))

Asks the receiving responder to validate the command.

[`canPerformAction(_:withSender:)`](/documentation/UIKit/UIResponder/canPerformAction(_:withSender:))

Requests the receiving responder to enable or disable the specified command in the user interface.

[`target(forAction:withSender:)`](/documentation/UIKit/UIResponder/target(forAction:withSender:))

Returns the target object that responds to an action.

### Accessing the available key commands

[`keyCommands`](/documentation/UIKit/UIResponder/keyCommands)

The key commands that trigger actions on this responder.

### Managing the text input mode

[`textInputMode`](/documentation/UIKit/UIResponder/textInputMode)

The text input mode for this responder object.

[`textInputContextIdentifier`](/documentation/UIKit/UIResponder/textInputContextIdentifier)

An identifier signifying that the responder should preserve its text input mode information.

[`clearTextInputContextIdentifier(_:)`](/documentation/UIKit/UIResponder/clearTextInputContextIdentifier(_:))

Clears text input mode information from the app’s user defaults.

[`inputAssistantItem`](/documentation/UIKit/UIResponder/inputAssistantItem)

The input assistant to use when configuring the keyboard’s shortcuts bar.

### Supporting user activities

[`userActivity`](/documentation/UIKit/UIResponder/userActivity)

An object encapsulating a user activity supported by this responder.

[`restoreUserActivityState(_:)`](/documentation/UIKit/UIResponder/restoreUserActivityState(_:))

Restores the state needed to continue the given user activity.

[`updateUserActivityState(_:)`](/documentation/UIKit/UIResponder/updateUserActivityState(_:))

Updates the state of the given user activity.

### Managing activity items

[`activityItemsConfiguration`](/documentation/UIKit/UIResponder/activityItemsConfiguration)

### Accessing the editing interaction

[`editingInteractionConfiguration`](/documentation/UIKit/UIResponder/editingInteractionConfiguration)

[`UIEditingInteractionConfiguration`](/documentation/UIKit/UIEditingInteractionConfiguration)

### Capturing text from the camera

[`captureTextFromCamera(_:)`](/documentation/UIKit/UIResponder/captureTextFromCamera(_:))

Starts scanning text using the device’s camera.

### Managing the Touch Bar

[`makeTouchBar()`](/documentation/UIKit/UIResponder/makeTouchBar())

Asks the receiving responder to create and configure a Touch Bar object.

[`touchBar`](/documentation/UIKit/UIResponder/touchBar)

The Touch Bar object for the responder.

### Constants

[`keyboardAnimationCurveUserInfoKey`](/documentation/UIKit/UIResponder/keyboardAnimationCurveUserInfoKey)

A user info key to retrieve the animation curve that the system uses to animate the keyboard onto or off the screen.

[`keyboardAnimationDurationUserInfoKey`](/documentation/UIKit/UIResponder/keyboardAnimationDurationUserInfoKey)

A user info key to retrieve the duration of the keyboard animation in seconds.

[`keyboardDidChangeFrameNotification`](/documentation/UIKit/UIResponder/keyboardDidChangeFrameNotification)

A notification that posts immediately after a change in the keyboard’s frame.

[`keyboardDidHideNotification`](/documentation/UIKit/UIResponder/keyboardDidHideNotification)

A notification that posts immediately after dismissing the keyboard.

[`keyboardDidShowNotification`](/documentation/UIKit/UIResponder/keyboardDidShowNotification)

A notification that posts immediately after displaying the keyboard.

[`keyboardFrameBeginUserInfoKey`](/documentation/UIKit/UIResponder/keyboardFrameBeginUserInfoKey)

A user info key to retrieve the keyboard’s frame at the beginning of its animation.

[`keyboardFrameEndUserInfoKey`](/documentation/UIKit/UIResponder/keyboardFrameEndUserInfoKey)

A user info key to retrieve the keyboard’s frame at the end of its animation.

[`keyboardIsLocalUserInfoKey`](/documentation/UIKit/UIResponder/keyboardIsLocalUserInfoKey)

A user info key to retrieve a Boolean value that indicates whether the keyboard belongs to the current app.

[`keyboardWillChangeFrameNotification`](/documentation/UIKit/UIResponder/keyboardWillChangeFrameNotification)

A notification that posts immediately prior to a change in the keyboard’s frame.

[`keyboardWillHideNotification`](/documentation/UIKit/UIResponder/keyboardWillHideNotification)

A notification that posts immediately prior to dismissing the keyboard.

[`keyboardWillShowNotification`](/documentation/UIKit/UIResponder/keyboardWillShowNotification)

A notification that posts immediately prior to displaying the keyboard.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)