Why can I not receive touch events within my custom UIScrollView subclass?

Posted by stefanosn on Stack Overflow See other posts from Stack Overflow or by stefanosn
Published on 2010-01-25T01:24:15Z Indexed on 2010/03/26 4:03 UTC
Read the original article Hit count: 475

Filed under:
|

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]);

}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch