Why can I not receive touch events within my custom UIScrollView subclass?
- by stefanosn
i have an uiscrollview with a uiimageview inside. I subclass the uiscrollview but i can not get touches to work touchbegin does not called. What should i do to call uitouch event?
what is wrong?
.h
#import <UIKit/UIKit.h>
@interface myScrollView : UIScrollView {
}
@end
.m
#import "myScrollView.h"
@implementation myScrollView
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (touch.view.tag > 0) {
touch.view.center = location;
}
NSLog(@"tag=%@", [NSString stringWithFormat:@"%i", touch.view.tag]);
}