手势

2017-07-21  本文已影响47人  我是小胡胡分胡

UIResponder->UIView->UIControl

1, UIResponder

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

state:possible/began/changed/ended/cancelled/failed
enable
cancelsTouchesInView
delaysTouchesBegan
delaysTouchesEnd
allowedTouchTypes
allowedPressTypes
requiresExclusiveTouchType

  1. 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

上一篇下一篇

猜你喜欢

热点阅读