UIResponder->UIView->UIControl
1, UIResponder
- (void)touchesXXXXX:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
2, UIGestureRecognizer
@interface UIView : UIResponder
@interface UIView (UIViewGestureRecognizers)
@property(nullable, nonatomic,copy) NSArray<__kindof UIGestureRecognizer *> *gestureRecognizers NS_AVAILABLE_IOS(3_2);
优先级最高响应,并忽略UIControl方法响应;
直接通过UIApplication直接向其派发消息,并且不再向响应者链派发消息。
[UIWindow sendEvent:] ---> [UIGestureEnvironment _updateGesturesForEvent:window:]--->
@interface UIGestureRecognizer (UIGestureRecognizerProtected)
// mirror of the touch-delivery methods on UIResponder
// UIGestureRecognizers aren't in the responder chain, but observe touches hit-tested to their view and their view's subviews
// UIGestureRecognizers receive touches before the view to which the touch was hit-tested
- (void)touchesXXXXX:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
state:possible/began/changed/ended/cancelled/failed
enable
cancelsTouchesInView
delaysTouchesBegan
delaysTouchesEnd
allowedTouchTypes
allowedPressTypes
requiresExclusiveTouchType
- UIControl
@interface UIControl : UIView
[UIWindow sendEvent:] ---》 [UIWindow _sendTouchesForEvent:]
会重写父类(UIResponder)的touchesXXXXX方法,可能会直接取消touchesCancelled/
highlighted
tracking
touchInside
selected
enabled
state:normal/highlighted/disabled/selected/focused/application/reserved
touchesBegan-> beginTrackingWithTouch
touchesEnded-> endTrackingWithTouch->target/action
touchesBegan-> beginTrackingWithTouch
touchesMoved-> continueTrackingWithTouch
touchesMoved-> continueTrackingWithTouch
touchesMoved-> continueTrackingWithTouch->pointinside
touchesEnded->pointinside-> endTrackingWithTouch
网友评论