在UIView上加载了一个UIScrollView(全屏),touches 事件捕获不到了

原因:UIView的touch事件被UIScrollView捕获了,无法传递下去

解决方法:写一个UIScrollView的category,在每个使用UIScrollView的地方将该类别导入

1、创建类别 file为UITouch class为UIScrollView

touches 事件捕获不到-LMLPHPtouches 事件捕获不到-LMLPHP

2、.m里内容

#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

3、在需要的界面#import该文件

04-30 04:49