tags:

views:

404

answers:

2

Hi,

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.

+1  A: 

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!

gcamp
What do you mean subclass UIScrollView? Thanks
sasayins
A: 

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.

luvieere