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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2021-06-05
  • 2021-07-31
猜你喜欢
  • 2021-11-27
  • 2021-11-26
  • 2022-01-09
  • 2021-05-30
  • 2021-08-28
  • 2021-11-11
  • 2021-12-09
相关资源
相似解决方案