1.UIApplication(继承自UIResponder)通过自己的UIWindow的- (void)sendEvent:(UIEvent *)event; // called by UIApplication to dispatch events to views inside the window方法将事件派发出去.
2.UIWindow首先将事件派发给手势识别器(级别高于响应者链),手势识别器不识别(UIGestureRecognizerStateFailed)后派发给window下的视图.
3.派发过程(手势识别失败的情况下)
The UIApplication object calls this method to dispatch events to the window. Window objects dispatch touch events to the view in which the touch occurred, and dispatch other types of events to the most appropriate target object.
这是官方原话,大致理解为派发事件,结合官方文档我个人做以下解释(不服请反驳):UIApplication拿到事件>- (void)sendEvent:(UIEvent *)event; 将事件交给 the touch occurred及触摸的视图,如果触摸的视图通过重写方法不处理该事件则会继续传递到下一个响应者(一般是superview)直到找到响应者,如果没有处理该事件则交由UIApplication最终抛弃。
4.派发过程中会调用- (nullable UIView *)hitTest:(CGPoint)point withEvent:(nullable UIEvent *)event; // recursively calls -pointInside:withEvent:. point is in the receiver's coordinate system这是一个抓测试的响应返回一个view及响应者,寻找的过程叫响应者链,通过重写此方法返回一个view拦截响应。
ios捕获并处理event的过程
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...