触摸事件。 窗口对象使用点击检测(hit-testing)以及响应链(responder chain) 来查找接收该触摸事件的视图。在点击检测中,<<<<一个窗口在视图层次的最上面的视图中调用hitTest:withEvent:; 如果这个方法返回YES,则在该视图层次的每!!!个视图上递归调用pointInside:withEvent:,>>>(不停的反复调用这两个方法。找到距离最远的最合适那个view。并且返回来)这样进行下去直到发现这个在触摸事件发生范围内的子视图。这个视图就成为hit-test 视图。
一下是辅助资料:
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent
{
}
http://blog.sina.com.cn/s/blog_87bed3110100t5cf.html
http://blog.csdn.net/iefreer/article/details/4754482
The implementation of
- It calls
pointInside:withEvent: of self - If the return is NO,
hitTest:withEvent: returns nil. the end of the story. - If the return is YES, it sends
hitTest:withEvent: messages to its subviews. it starts from the top-level subview, and continues to other views until a subview returns a non-nil object, or all subviews receive the message. - If a subview returns a non-nil
object in the first time, the first hitTest:withEvent: returns that object. the end of the story. - If no subview returns a non-nil
object, the first hitTest:withEvent: returns self
This process repeats recursively, so normally the leaf view of the view hierarchy is returned eventually.
However, you might override