Raptor
Raptor

Reputation: 54222

Adding UINavigationController to xCode Tab Bar Application Template

How to add UINavigationController to xCode Tab Bar Application Delegate?

My structure is based on xCode Tab Bar Application Delegate, with 2 tabs, First View & Second View respectively. For First View, I added a UITableView. I just want to make use of UINavigationController function [self.navigationController pushViewController:animated:] to push a subview and allow a navigation bar to be shown in subview. After pushing the subview, the tab bar must still be there.

Sounds simple, but I have no idea how to achieve it. Please help.

Upvotes: 0

Views: 1410

Answers (2)

Krishnachandra Sharma
Krishnachandra Sharma

Reputation: 1342

I did this using presentModalViewController:animated . I added tabBar Controller in the modalView. In the method didSelectRowAtIndexPath use this presentModalViewController:animated .I might not be perfect but I had the same problem, but now my app works as I need.

Upvotes: 1

rjgonzo
rjgonzo

Reputation: 1761

I started with a Window-based template instead and did this to achieve the same thing.

I created my NavigationControllers and TabBarController in my app delegate manually.

In your:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Add this:

//Seeting up the Navigation controllers and pushing our TableView controllers.  
UINavigationController *unvc1 = [[UINavigationController alloc] init];
UINavigationController *unvc2 = [[UINavigationController alloc] init];
[unvc1 pushViewController:someViewController1 animated:NO];
[unvc2 pushViewController:someViewController2 animated:NO];
[someViewController1 release];[someViewController2 release];//Releasing our TableView controllers. 

//Setting up the TabBar controller and pushing our Navigation controllers. 
UITabBarController *tbvc = [[UITabBarController alloc] init];
tbvc.viewControllers = [NSArray arrayWithObjects:unvc1, unvc2, nil];
[unvc1 release];[unvc2 release]; //releasing our Navigation controllers. 

I hope this helps.

Upvotes: 1

Related Questions