Learn how to handle events that propagate through your app.
Apps receive and handle events using responder objects. A responder object is any instance of the UIResponder
class, and common subclasses include UIView
, UIViewController
, and UIApplication
. Responders receive the raw event data and must either handle the event or forward it to another responder object. When your app receives an event, UIKit automatically directs that event to the most appropriate responder object, known as the first responder.
UIView
, UIViewController
, UIApplication
이 포함됩니다.UIKit
은 자동으로 해당 이벤트를 First responder로 알려진 가장 적절한 responder 객체에게 보냅니다.Unhandled events are passed from responder to responder in the active responder chain, which is the dynamic configuration of your app’s responder objects. Figure 1 shows the responders in an app whose interface contains a label, a text field, a button, and two background views. The diagram also shows how events move from one responder to the next, following the responder chain.
Figure 1 Responder chains in an app
If the text field does not handle an event, UIKit sends the event to the text field’s parent UIView
object, followed by the root view of the window. From the root view, the responder chain diverts to the owning view controller before directing the event to the window. If the window cannot handle the event, UIKit delivers the event to the UIApplication
object, and possibly to the app delegate if that object is an instance of UIResponder
and not already part of the responder chain.