touchesBegan: withEvent: Do not perform resolution
- 2021-08-21 21:37:59
- OfStack
touchesBegan: withEvent:/touchesMoved: withEvent:/touchesEnded: withEvent: etc. can only be captured by UIView (if there is any problem, please point it out, please don't spray it when passing Daniel), when we create
When UIScrollView or UIImageView is clicked, UIScrollView or UIImageView intercepts the touch event, causing touchesBegan: withEvent:/touchesMoved: withEvent:/touchesEnded: withEvent: and so on not to execute. Solution: When UIScrollView or UIImageView intercepts an touch event, let it pass on (that is, pass it to its parent view UIView)
This can be done by writing category of UIScrollView or UIImageView and overwriting touchesBegan: withEvent:/touchesMoved: withEvent:/touchesEnded: withEvent: etc
//
// UIScrollView+UITouch.m
//
//
// Created by MLS on 15/11/20.
// Copyright © 2015 Year mls. All rights reserved.
//
#import "UIScrollView+UITouch.h"
@implementation UIScrollView (UITouch)
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
// Choose it 1 You can
[super touchesBegan:touches withEvent:event];
// [[self nextResponder] touchesBegan:touches withEvent:event];
}
@end