UIResponder introduction, uiresponder

Source: Internet
Author: User

UIResponder introduction, uiresponder

This UIResponder class defines the object interfaces for responding to and processing events. It is a superclass (UIWindow) of UIView and UIApplication ). Instances of these classes are sometimes called response objects. Simply put, they are the response objects.

 

There are usually two types of events: Touch events and mobile events.

  Main methods for processing touch events

1.TouchesBegan: withEvent:

2.TouchesMoved: withEvent:

3.TouchesEnded: withEvent:

4.TouchesCancelled: withEvent:

Parameters of these methods are associated with the touch events, and changes to the start touch and touch position will occur. Therefore, iOS allows the responder to track and process the touch separately in multi-touch mode.As long as you touch the screen, slide, and exit from the screen, a UIEvent object is generated, including the UITouch object.

Main methods for handling mobile events

1. motionBegan: withEvent:

2. motionEnded: withEvent:

3. motionCancelled: withEvent:

In addition, the canonicalizedmaction: withSender: method allows the Response Program to verify commands in the user interface, while the undoManager attribute returns the most recent NSUndoManager object in the response chain.

The UIEventType struct defines the event type.

 

typedef NS_ENUM(NSInteger, UIEventType) {    UIEventTypeTouches,    UIEventTypeMotion,    UIEventTypeRemoteControl,#ifndef SDK_HIDE_TIDE    UIEventTypePresses NS_ENUM_AVAILABLE_IOS(9_0),#endif};

 

  

  Manage the responder chain

   -(Nullable UIResponder *) nextResponderReturns the next responder of the current receiver. If no nil is returned. Let the next object in the response chain process the event. By default, the UIResponder class returns nil and does not automatically store or set the next responder. Therefore, its subclass must override this method to set the next responder. Is the delivery order of the responder chain, -(BOOL) isFirstResponderDetermine whether the recipient is the first responder. If YES is returned, the message receiver is the first responder, and vice versa. -(BOOL) becomeFirstResponderThe notification recipient is about to become the first responder in its window. YES is returned by default. -(BOOL) resignFirstResponderThe current receiver is released as the first responder. -(BOOL) canResignFirstResponderDetermine whether the receiver can release the first responder. Yes is returned, but cannot be removed. Manage input View    @ Property (nullable, nonatomic, readonly, strong) _ kindof UIView * inputView   Custom view displayed when the Receiver becomes the first responder. This attribute is usually used to provide a view to replace the system keyboard provided by the UITextField and UITextView objects. It is a read-only attribute. When the recipient becomes the first responder, the view is automatically displayed. When the first responder is removed, the view should disappear automatically.   @ Property (nullable, nonatomic, readonly, strong) UIInputViewController * inputViewControllerSame as above. -(Void) reloadInputViewsWhen the receiver is the first responder, the input view or subview is updated. Respond to touch events

-(Void) touchesBegan :( NSSet <UITouch *> *) touches withEvent :( nullable UIEvent *) event

It occurs when you start to touch the screen. Touches is a collection of UITouch instances for event touch. Event is the object that causes the event.

  

-(Void) touchesMoved :( NSSet <UITouch *> *) touches withEvent :( nullable UIEvent *) event

Occurs when one or more fingers move in the screen

 

-(Void) touchesEnded :( NSSet <UITouch *> *) touches withEvent :( nullable UIEvent *) event

Occurs when one or more fingers exit the screen.

 

-(Void) touchesCancelled :( nullable NSSet <UITouch *> *) touches withEvent :( nullable UIEvent *) event

When the touch is canceled (memory is tight)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.