所有控件的多点触摸默认是关闭的。需要使用多点触摸时要手动打开。
UIView的属性:保存是否打开多点触摸的属性
@property(nonatomic,getter=isMultipleTouchEnabled)BOOL multipleTouchEnabled __TVOS_PROHIBITED; // default is NO
UIView的属性:保存当子控件超出父控件的视图范围时是否对子控件进行裁剪的属性
@property(nonatomic) BOOL clipsToBounds; //When YES, content and subviews are clipped to the bounds of the view. Defaultis NO.
控件不能响应用户交互的情况:
1、userinteraction == NO
2、hidden ==YES
3、alphas <=0.01
4、子视图超出父控件的有效范围
触摸事件的产生:响应者链条
手指触摸控件 -> View ->rootViewController -> UIWindow -> app -> 运行循环 ->UIWindow -> rootViewController-> View -> 子控件(touchbegan)
UIView的方法:寻找响应者控件的方法
- (nullable UIView *)hitTest:(CGPoint)pointwithEvent:(nullable UIEvent *)event; //recursively calls -pointInside:withEvent:. point is in the receiver'scoordinate system
模拟hiTest的实现,寻找子控件时默认从后向前进行遍历
拖拽的UIImageView和纯代码创建的UIImageView控件的UserInteractionEnabled默认为NO
从媒体库拖出来的UIImageView有大小,默认UserInteractionEnabled为YES