Reputation: 16029
I have a UIScrollView in my view control but my UIScrollView can't catch the touchBegan. touchBegan only execute when touching outside of the UIScrollView. How can catch the touchBegan when touching UIScrollView?
Thanks.
Upvotes: 0
Views: 838
Reputation: 37494
In order to subclass UIScrollView, your MyUIScrollView.h file should look similar to this:
#import <UIKit/UIKit.h>
@interface MyUIScrollView : UIScrollView {
}
@end
Then, in your MyUIScrollView.m, you place your touchesBegan method:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
After you do this, anywhere in your code where you now use an UIScrollView, you switch to using a MyUIScrollView.
Upvotes: 0
Reputation: 14662
You must subclass UIScrollView
(or an other view) and re-implement the methods you want to catch. Don't forget to call super in you implementation!
Upvotes: 1