Learning records for events in iOS

Source: Internet
Author: User

Touch events fall into three categories

  • Touch events (single point, multi-touch, and various gesture operations)
  • Sensor events (gravity, accelerometer, etc)
  • Remote Control event (Remote Control of iOS device multimedia playback, etc)


    Touch events are divided into situations where gestures are added or not added. If a gesture is added, the gesture intercepts the click event. there are several types of gestures, such as clicking, holding, and dragging. if you click an event, the status will change from identifiable to successful or failed. If you click the event, the status will change from recognizable to failed or start, recognized or canceled.


    UITouch

    • TouchesBegan: withEvent:
    • TouchesMoved: withEvent:
    • TouchesEnded: withEvent:
    • TouchesCancelled: withEvent:



      Responder chain

      Hit-test view

      HitTest: withEvent: the process is as follows:

      First, call the pointInside: withEvent: Method of the current view to determine whether the touch point is in the current view;

      If NO is returned, hitTest: withEvent: nil is returned;

      If YES is returned, hitTest: withEvent: message is sent to all subviews in the current view. The traversal order of all subviews is from the top-level view to the bottom-level view, that is, it traverses forward from the end of the subviews array until a subview returns non-empty objects or all subviews are traversed;

      If a child view returns a non-null object for the first time, the hitTest: withEvent: method returns this object, and the process ends;

      If none of the Child views are returned, the hitTest: withEvent: method returns itself (self ).


      Event Transfer Mechanism

      View is passed to the next layer. If the previous layer does not affect the operation, it will continue to be passed to the next layer and be passed to rootVC. If the rootvc does not support the operation, it will be passed to windows, if windows does not support the event, the event will be passed to the application. If it does not support the event, the touch event will be discarded.


      Reference: iOS event mechanism Cocoa Touch event handling process-responder chain

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.