mirror of
https://github.com/NohamR/knowledge-kit.git
synced 2026-05-24 20:00:37 +00:00
docs: APM 监控部分
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
# hittest方法
|
||||
# 事件响应者判定原理之 hittest 方法
|
||||
|
||||
## 一、 hittest 介绍
|
||||
* 就是用来寻找最合适的view
|
||||
* 当一个事件传递给一个控件,就会调用这个控件的hitTest方法
|
||||
* 点击了白色的view: 触摸事件 -> UIApplication -> UIWindow 调用 \[UIWindow hitTest\] -> 白色view \[WhteView hitTest\]
|
||||
|
||||
实验1:
|
||||
|
||||
## 二、 实验
|
||||
|
||||
### 2.1 实验一
|
||||
|
||||
定义 BaseView,在里面实现方法touchBegan,监听当前哪个类调用了该方法。
|
||||
|
||||
@@ -15,9 +19,8 @@
|
||||

|
||||
|
||||
|
||||
```
|
||||
```Objective-C
|
||||
//KeyWindow
|
||||
|
||||
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
|
||||
UIView *view = [super hitTest:point withEvent:event];
|
||||
NSLog(@"fittest->%@",view);
|
||||
@@ -25,11 +28,9 @@
|
||||
}
|
||||
```
|
||||
|
||||
结果:
|
||||
|
||||
点击了白色1:
|
||||
|
||||
```
|
||||
```shell
|
||||
2017-10-11 16:48:52.882547+0800 主流App框架[16295:358790] BrownView--hitTest withEvent
|
||||
2017-10-11 16:48:59.646610+0800 主流App框架[16295:358790] GreenView--hitTest withEvent
|
||||
2017-10-11 16:48:59.647145+0800 主流App框架[16295:358790] fittest-><UIView: 0x7f8f23406510; frame = (0 0; 414 736); autoresize = W+H; layer = <CALayer: 0x60c000221840>>
|
||||
@@ -40,7 +41,7 @@
|
||||
|
||||
点击了蓝色3:
|
||||
|
||||
```
|
||||
```shell
|
||||
2017-10-11 16:49:56.331024+0800 主流App框架[16295:358790] BrownView--hitTest withEvent
|
||||
2017-10-11 16:49:56.331335+0800 主流App框架[16295:358790] BView--hitTest withEvent
|
||||
2017-10-11 16:49:56.331617+0800 主流App框架[16295:358790] BlueView--hitTest withEvent
|
||||
|
||||
Reference in New Issue
Block a user