touchesBegan and other touch events not getting detected in UINavigationController

Posted by SaltyNuts on Stack Overflow See other posts from Stack Overflow or by SaltyNuts
Published on 2010-06-14T16:36:43Z Indexed on 2010/06/14 17:02 UTC
Read the original article Hit count: 345

In short, I want to detect a touch on the navigation controller titlebar, but having trouble actually catching any touches at all!

Everything is done without IB, if that makes a difference.

My app delegate's .m file contains:

MyViewController *viewController = [[MyViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:navigationController.view];

There are a few other subviews added to this window in a way that overlays navigationController leaving only the navigation bar visible.

MyViewController is a subclass of UIViewController and its .m file contains:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
 for (UITouch *touch in touches) {
  NSLog(@"ended\n");
 } 

}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
 for (UITouch *touch in touches) {
  NSLog(@"began\n");
 } 
}

I also tried putting these functions directly into app delegate's .m file, but the console remains blank.

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk-3.0