iOS hitTest:withEvent:

touch事件发生时,iOS 系统检测touch事件, 调用相应framework生成event,此event被加入到iOS 系统当前的active app事件队列,application object接收到事件,然后UIApplication调用senderEvent分发事件,事件被传递至UIWIndow(大多由keyWindow接收),UIWindow调用hitTest:withEvent: 确定firstResponder:

opaque==0或者hide的view不接收事件


hitTest:WithEvent: 调用过程为



hitTest:withEvent: ===>调用pointInside:withEvent: ===> (point函数返回NO,结束分支,返回nil) // 返回YES ===> (当前view没有subview,hitTest返回self) // 当前view有subviews ===>从subviews的最上层view开始遍历,递归调用hitTest:withEvent:,直到hitTest返回第一个非nil对象 ===>(hitTest:withEvent:)

你可能感兴趣的:(iPhone)