How to catch touchBegan by other subviews such us UIScrollView
I have a UIScrollView in my view control but my UIScrollView can't catch the touchBegan. touchBegan only execute开发者_如何学Python when touching outside of the UIScrollView. How can catch the touchBegan when touching UIScrollView?
Thanks.
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!
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.
精彩评论