iOS Learning notes-touch events

Source: Internet
Author: User

I. The process of event delivery
1. The user fingers touch the screen, resulting in an event object

2. The event object is added to the event queue (FIFO)

3. Processing of event objects in the event queue taken by uiapplication

4.UIApplication will first pass the event object to the primary UIWindow
(Of course, you must first detect if UIWindow can receive and deliver events)

5.UIWindow iterates through all the child controls to see if the touch points fall on one of the child controls:

1> If the touch point does not fall on the child control, then the event is handled directly by UIWindow, and the event is passed

2> if the touch point falls on the child control V1, then iterate through all of the V1 's child controls, repeating the previous 5 steps
(The last child control starts the traversal)

6. Eventually, a UIView object that is best suited to handle the event is sent, and the corresponding message is given to the UIView object, that is, the corresponding method of calling UIView (Touchesbegan ...), informing it that it was touched.


Second, the process of event processing

(That is, Touchesbegan, touchesmoved, touchesended method Internal processing process)

If you override these 3 methods and do not call back the Super method, the default behavior of the parent class is ignored

1. Default Practice:
1> the event object along the responder chain and eventually passes it to the uiapplication

2> if the middle chain breaks, it's not going to go up.

2. Overriding the default behavior of the parent class, the event will not be passed up, and the responder chain will be broken off

3. The transmission of events and the handling of events are essentially reciprocal processes


Three, Pointinside:withevent: method

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.