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

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM