touchesBegan: withEvent: / touchesMoved: withEvent: / touchesEnded: withEvent: etc. can only be captured by UIView (if you have any questions, please point it out, please do not spray the passing big bulls). When we create
UIScrollView orUIImageViewWhen clickedUIScrollViewor UIImageView The touch event will be intercepted, causing the touchesBegan: withEvent:/touchesMoved: withEvent:/touchesEnded: withEvent: and other methods not to be executed. Solution: After UIScrollView or UIImageView intercepts the touch event, let it pass it (that is, pass it to its parent view UIView)
You can do this by writing UIScrollView or UIImageView's category override touchesBegan: withEvent: / touchesMoved: withEvent: / touchesEnded: withEvent: etc.
// // UIScrollView+ // // // Created by MLS on 15/11/20. // Copyright © 2015 mls. All rights reserved.// #import "UIScrollView+" @implementation UIScrollView (UITouch) - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { // Just choose one [super touchesBegan:touches withEvent:event]; // [[self nextResponder] touchesBegan:touches withEvent:event]; } @end