views:

2197

answers:

1

Hi I'm having this problem:

I have a UITabBarController with UINavigationControllers in each tab.

However, I'm trying to implement an action that, when I click on a button, should present me a new view with a UINavigationController (since it will be multi-view) in a modal way.

What I've tried is to implement a new UIViewController, with a NavigationBar. And then on the button handler I wrote something like this:

SendMessageViewController *v = [[SendMessageViewController alloc] initWithNibName:@"SendMessageView" bundle:nil];
UINavigationController *t = [[UINavigationController alloc] initWithRootViewController:v];
[(UINavigationController *)[tabbar.viewControllers objectAtIndex:0] presentModalViewController:t animated:true]; // hardcoding 0, I know

However, the modal view that's pushed appears with 2 navigation bars, one empty, and my other defined on the "SendMessageView" XIB.

Is there a way to solve this? I don't want to create a XIB just to contain a UINavigationController.. I thought I could do it programatically.

+1  A: 

What you want to do is this:

[tabBarController presentModalViewController:t animated:Y];

Basically, get a handle to the tab bar ViewController, and then you'll have the single nav bar you were seeking.

Kendall Helmstetter Gelner
Hi Kendall. Thank for you answer. I've tried your code and it still doesn't work, I still have a double bar showing :( I must be doing something wrong elsewhere :(
rubenfonseca
Sorry about that, could have sworn it would work - I know it's possible.
Kendall Helmstetter Gelner