touches 事件捕获不到

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

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

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

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

touches 事件捕获不到touches 事件捕获不到

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该文件

上一篇:4.9---二叉树路径和(CC150)


下一篇:HTML5入门4---HTML5 与 HTML4 同一网页的不同写法