iOS開發(fā)UIScrollView的touchesBegan和touchesEnd
作者:佚名
本文為大家介紹了iOS開發(fā)UIScrollView的touchesBegan和touchesEnd。touchesBegan跟touchedEnd沒有提供給UIScrollViewDelegate,所以要自己建立一個(gè)繼承自UIScrollView的class,重寫這兩個(gè)method。
touchesBegan跟touchedEnd沒有提供給UIScrollViewDelegate
所以要自己建立一個(gè)繼承自UIScrollView的class
重寫這兩個(gè)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建立 即可使用這兩個(gè)method
- myScrollView *contentScrollView = [[myScrollView alloc] init];
責(zé)任編輯:閆佳明
來源:
apkbus