QHP_22事件处理
2016-05-12 本文已影响16人
风信子的梦想成真

响应者对象:在iOS中不是任何对象都能处理事件,只有继承了UIResponder的对象才能接收并处理事件,我们称之为“响应者对象”,UIApplication,UIController,UIView都继承自UIResponder,因此它们都是响应者对象,都能够接收并处理事件。



UITouch 当用户用一根手指触摸屏幕时,会创建一个与手指相关联的UITouch对象,一根手指对应一个UITouch对象
UITouch作用

UITouch实现拖拽


事件的产生和传递

UIView不接收触摸事件的三种情况
1.不接收用户交互userInteractionEnabled = NO;
2.隐藏 hidden = YES;
3.透明 alpha 0.0 ~ 0.01,
提示:UIImageView的userInterationEnabled默认就是NO,以为UIImageView以及它的子控件默认是不能接收触摸事件的

事件处理自定义window
自定义window的时候加载

在自定义的window里面写上调用hitTest:withEvent:

point:当前的触摸点,point这个点的坐标系就是方法的调用者