Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analyze the response chain and delivery chain of events in iOS

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "analyzing the response chain and delivery chain of events in iOS". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "analyzing the response chain and delivery chain of events in iOS".

There are two iOS event chains: the response chain of events and the delivery chain of Hit-Testing events.

Response chain: passed to the system by the view closest to the user. Initial view-> super view->... .. -> view controller-> window-> Application-> AppDelegate delivery chain: passed from the system to the nearest view to the user. UIKit-> active app's event queue-> window-> root view->. -> lowest view

In iOS, only objects that inherit UIResponder can receive and handle events. UIResponder is the base class of all response objects, and interfaces for handling these events are defined in the UIResponder class. The familiar UIApplication, UIViewController, UIWindow and all the UIKit classes that inherit from UIView inherit directly or indirectly from UIResponder, so their examples are responder objects that can form a responder chain. First of all, let's take a brief look at the transmission and response of events through a diagram.

1. Transfer chain

Two core methods of event delivery

-(nullable UIView *) hitTest: (CGPoint) point withEvent: (nullable UIEvent *) event; / / recursively calls-pointInside:withEvent:. Point is in the receiver's coordinate system- (BOOL) pointInside: (CGPoint) point withEvent: (nullable UIEvent *) event; / / default returns YES if point is in bounds

The first method returns a UIView, which is used to find out which view will respond to the event.

The second method is used to determine whether the location of a click is within the view range, and if so, return YES

Among them, UIView does not accept event handling.

1. Alpha

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report