Why my own UIViewController can't detect touch?

Posted by Tattat on Stack Overflow See other posts from Stack Overflow or by Tattat
Published on 2010-05-02T18:53:23Z Indexed on 2010/05/02 18:58 UTC
Read the original article Hit count: 381

Filed under:
|

I have my OwnViewController, the viewDidLoad is like this:

    - (void)viewDidLoad {
        [super viewDidLoad];
        UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"myImg" ofType:@"png"]];
        CGRect cropRect = CGRectMake(175, 0, 175, 175);
        CGImageRef imageRef = CGImageCreateWithImageInRect([img CGImage], cropRect);

        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 175, 175)];
        imageView.image = [UIImage imageWithCGImage:imageRef];
        self.view = imageView;

        CGImageRelease(imageRef);
}

It works, and I have detect touches method like this:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesBegan");
}

But my UIView can't detect any touches. My Own UIViewController is a subclass of UIViewController. It is a little square view on the IB, why that can't detect touches? thx u.

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0

Related posts about objective-c