iOS开发笔记

iOS事件的传递、分发及响应过程总结

2018-09-04  本文已影响0人  Jason_Lou
  1. 查找合适的View
    产生触摸事件 → UIApplication事件队列 → UIWindow的hitTest:withEvent:→ UIView的hitTest:withEvent: → 子View的hitTest:withEvent: → 子View的hitTest:withEvent:
  1. 事件分发
    UIApplication sendEvent: → UIWindow sendEvent: → 最合适的view开始响应
  1. 事件响应
    根据事件类型调用对应方法,以touchBegan为例:
    最合适的view touchesBegan: withEvent: → 所在ViewController touchesBegan: withEvent:→ parentView touchesBegan: withEvent: → ... → UIWindow touchesBegan: withEvent: → UIAplication touchesBegan: withEvent: → AplicationDelegate touchesBegan: withEvent: → 结束
上一篇 下一篇

猜你喜欢

热点阅读