首页 > 其他 > 详细

touches 事件捕获不到

时间:2016-07-21 14:51:38      阅读:165      评论:0      收藏:0      [点我收藏+]

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

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

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

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

技术分享技术分享

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

 

touches 事件捕获不到

原文:http://www.cnblogs.com/huaixu/p/5691605.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!