首页 > 代码库 > UIScrollView 与 touchesBegan 冲突解决方法

UIScrollView 与 touchesBegan 冲突解决方法

给UIScrollView写一个延展 

.h文件实现:

@interface UIScrollView (NSFoundation)

@end

.m文件实现

@implementation UIScrollView (ScrollTouch)

//重写touchesBegin方法   

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

//主要代码实现:

    [[self nextResponder] touchesBegan:touches withEvent:event];

//super调用,别漏

    [super touchesBegan:touches withEvent:event];

}

 

//重写touchesEnded方法   

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

[[self nextResponder] touchesEnded:touches withEvent:event];

[super touchesEnded:touches withEvent:event];

}

 

//重写touchesMoved方法   

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

[[self nextResponder] touchesMoved:touches withEvent:event];

[super touchesMoved:touches withEvent:event];

}

 

 

 

@end

 

 

 

UIScrollView 与 touchesBegan 冲突解决方法