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