I have an iOS app in which I add a UINavigationController
as a child view controller to the main screen. It's arranged vertically, so that the nav controller takes up a bottom part of the main view's height and is full-width. There is a button (actually a custom view with a tap recognizer) that sits right above the nav that is used to hide and show it; when the nav is hidden, the button is at the bottom of the main screen, and when the nav is shown the button is right above the top of the nav bar.
The issue is that the navigation bar appears to intercept touches on the bottom 10 points or so of the button. Why is this?
The code to add the child looks like this:
UIViewController *root = [[[UIViewController alloc]init]autorelease]; //some VC
UINavigationController *nav = [[[UINavigationController alloc]initWithRootViewController:root]autorelease];
[self addChildViewController:nav];
CGRect rect = self.view.frame;
CGFloat height = 500;
nav.view.frame = CGRectMake(0, rect.size.height - height, rect.size.width, height);
[self.view addSubview:nav.view];
[nav didMoveToParentViewController:self];
//Now the button
UIView *view = [[[UIView alloc]initWithFrame:CGRectZero]autorelease];
view.backgroundColor = [UIColor greenColor];
[self.view addSubview:view];
view.frame = CGRectMake(0, rect.size.height - 500 - 40, rect.size.width, 40);
UITapGestureRecognizer *recog = [[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onToggleSplit)]autorelease];
[view addGestureRecognizer:recog];
onToggleSplit
animates the nav up and down. When it's up, taps on the bottom 10 points or so of the "button" do nothing. I tried overriding touchesBegan
on my custom "button" view, and that doesn't even get called.
If I use a regular UIViewController
(or a subclass thereof) for the child VC, the button responds as expected.