UIResponder

3296 단어
응답자 객체
Responder objects—that is, 
instances of UIResponder—constitute the event-handling backbone of a UIKit app. 
Many key objects are also responders, including the UIApplication object, 
UIViewController objects, and all UIView objects (which includes UIWindow). 
As events occur, UIKit dispatches them to your app's responder objects for handling.

응답자 객체 - 즉 UIresponder의 인스턴스는 이벤트 처리를 구성하는 핵심 컨텐트입니다.많은 주요 대상은 응답자 대상인데, UIAPplication, UIViewController, UIView와 UIView에서 계승된 클래스 (UIWindow 포함) 를 포함한다.이벤트가 트리거될 때 UIKit는 이를 앱의 응답자 대상에 나누어 처리합니다.
이벤트 처리
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:),
 touchesMoved(_:with:),
 touchesEnded(_:with:), 
 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.

이벤트는 터치, 운동, 리모컨, 압력(iOS9.0 이후 사용 가능) 등으로 나뉜다.응답자 대상은 대응하는 방법을 실현해야만 특정 유형의 이벤트를 처리할 수 있다.예를 들어 응답자의 대상은 다음과 같은 몇 가지 방법으로 터치 이벤트를 처리할 수 있다. 터치 이벤트(: with:) 터치 Moved(: with:) 터치 Ended(: with:) 터치 이벤트에서 응답자는 UIKite가 제공하는 이벤트 메시지를 통해 이러한 터치 이벤트의 변화를 추적하여 인터페이스를 정확하게 업데이트할 수 있다.
이벤트 전달
In addition to handling events, UIKit responders also 
manage the forwarding of unhandled events to other parts of your app. 
If a given responder does not 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.

이벤트를 처리할 수 있는 것 외에 UIKit의 응답자 대상도 처리되지 않은 이벤트를 앱의 다른 부분으로 전송할 수 있습니다.지정한 응답자 대상이 이벤트를 처리하지 않으면, 이벤트를 응답자 체인의 다음 응답자에게 전송합니다.UIKite는 응답자 체인을 자동으로 관리합니다. 미리 정의된 규칙을 통해 다음 이벤트의 응답자를 결정합니다.예를 들어 하나의view는 이벤트를 슈퍼뷰에 전달하고, 차원 구조의 루트view는 이벤트를 보기 컨트롤러에 전달합니다.
입력 뷰 작업
Responders process 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 and 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
property of the responder.

응답자 대상은 이벤트 대상을 처리할 수 있고, 입력 보기를 통해 사용자 정의 입력을 받아들일 수 있습니다.시스템 키보드는 가장 뚜렷한 입력 보기의 예이다.사용자가 화면에서 UITExtField와 UITExtView를 눌렀을 때, 이 보기는 첫 번째 응답자가 되어 입력 보기: 시스템 키보드를 동시에 보여 줍니다.마찬가지로 다른 응답자가 활성화되었을 때 사용자 정의 입력 보기를 만들어서 표시할 수도 있습니다.사용자 정의 보기와 응답자를 연결하기 위해서는 응답자의 대상에 inputView를 속성으로 정의해야 합니다
총결산
응답자 대상 정의: UIresponder의 실례적인 역할: 이벤트를 처리할 수 있고, 처리할 수 없는 것은 이벤트를 다른 역할로 전달할 수 있다. 입력 보기, 예를 들어 키보드 입력을 처리하는 것이다.일반 UITExtField 및 UITExtView는 클릭 시 자동으로 시스템의 입력 뷰 - 키보드

좋은 웹페이지 즐겨찾기