iOS开发中touchesBegan和touchesEnd的使用

Posted on 2013-11-22 10:15  逍_遥  阅读(1229)  评论(0)    收藏  举报
touchesBegantouchedEnd沒有提供給UIScrollViewDelegate
所以要自己建立一個繼承自UIScrollViewclass
重寫這兩個method
myScrollView.h
@interface myScrollView : UIScrollView 
@end 
myScrollView.m
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 
[super touchesBegan:touches withEvent:event]; 
if ( !self.dragging ) 
[[self nextResponder] touchesBegan:touches withEvent:event]; 
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ 
[super touchesEnded:touches withEvent:event]; 
if ( !self.dragging ) 
[[self nextResponder] touchesEnded:touches withEvent:event]; 
之後建立UIScrollView就是用myScrollView建立即可使用這兩個method
myScrollView *contentScrollView = [[myScrollView alloc] init];

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3