关于UIScrollView不能响应UITouch事件的解决办法

原因是:UIView的touch事件被UIScrollView捕获了。

#import "UIScrollView+UITouch.h"

@implementation UIScrollView (UITouch)

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (![self isMemberOfClass:[UIScrollView class]]) {

} else {
    [[self nextResponder] touchesBegan:touches withEvent:event];
    if ([super respondsToSelector:@selector(touchesBegan:withEvent:)]) {
        [super touchesBegan:touches withEvent:event];
    }
}

}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if (![self isMemberOfClass:[UIScrollView class]]) {

} else {
    [[self nextResponder] touchesMoved:touches withEvent:event];
    if ([super respondsToSelector:@selector(touchesBegan:withEvent:)]) {
        [super touchesMoved:touches withEvent:event];
    }
}

}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if (![self isMemberOfClass:[UIScrollView class]]) {

} else {
    [[self nextResponder] touchesEnded:touches withEvent:event];
    if ([super respondsToSelector:@selector(touchesBegan:withEvent:)]) {
        [super touchesEnded:touches withEvent:event];
    }
}

}

@end

你可能感兴趣的:(关于UIScrollView不能响应UITouch事件的解决办法)