UIScrollView覆盖在底层的UIView上面会接收UITouch的事件,事件就不会向下传递了,这时需要添加一个类别来让UISrollView不接收这个事件并把这个事件传递下去,创建如下类别在需要的文件中导入这个类别即可。
#import "UIScrollView+UITouch.h"
@implementation UIScrollView (UITouch)
- (
void
)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[[self nextResponder] touchesBegan:touches withEvent:event];
[super touchesBegan:touches withEvent:event];
}
-(
void
)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[[self nextResponder] touchesMoved:touches withEvent:event];
[super touchesMoved:touches withEvent:event];
}
- (
void
)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[[self nextResponder] touchesEnded:touches withEvent:event];
[super touchesEnded:touches withEvent:event];
}
@end