所有控件的多點觸摸默認(rèn)是關(guān)閉的趣斤。需要使用多點觸摸時要手動打開讨衣。
UIView的屬性:保存是否打開多點觸摸的屬性
@property(nonatomic,getter=isMultipleTouchEnabled)BOOL multipleTouchEnabled __TVOS_PROHIBITED; // default is NO
UIView的屬性:保存當(dāng)子控件超出父控件的視圖范圍時是否對子控件進(jìn)行裁剪的屬性
@property(nonatomic) BOOL clipsToBounds; //When YES, content and subviews are clipped to the bounds of the view. Defaultis NO.
控件不能響應(yīng)用戶交互的情況:
1、userinteraction == NO
2没炒、hidden ==YES
3涛癌、alphas <=0.01
4、子視圖超出父控件的有效范圍
觸摸事件的產(chǎn)生:響應(yīng)者鏈條
手指觸摸控件 -> View ->rootViewController -> UIWindow -> app -> 運(yùn)行循環(huán) ->UIWindow -> rootViewController-> View -> 子控件(touchbegan)
UIView的方法:尋找響應(yīng)者控件的方法
- (nullable UIView *)hitTest:(CGPoint)pointwithEvent:(nullable UIEvent *)event; //recursively calls -pointInside:withEvent:. point is in the receiver'scoordinate system
模擬hiTest的實現(xiàn),尋找子控件時默認(rèn)從后向前進(jìn)行遍歷
拖拽的UIImageView和純代碼創(chuàng)建的UIImageView控件的UserInteractionEnabled默認(rèn)為NO
從媒體庫拖出來的UIImageView有大小送火,默認(rèn)UserInteractionEnabled為YES