Reputation: 749
I have a window based app. I added two viewcontrollers and one Tabbarcontroller
to that. Now I want to navigate each viewcontroller to next view. I tried but can't find the solution. Can anyone please help me?
Upvotes: 1
Views: 239
Reputation: 12787
use like this
secondViewController *obj=[[[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil] autorelease];
UINavigationController *navBar=[[UINavigationController alloc] initWithRootViewController:obj];
[self.navigationController pushViewController:navBar animated:YES];
[navBar release];
Upvotes: 1
Reputation: 26400
UINavigationController *urNavController = [[UINavigationController alloc] initWithRootViewController:rootController];
If you want to show this on the window
[window addSubview:urNavController.view];
Upvotes: 1
Reputation: 2344
When you add the tab bar on window, add like this-
NSMutableArray * viewControllers = [[NSMutableArray alloc]init];
FirstViewController * firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[firstViewController release];
[viewControllers addObject:nvc];
[nvc release];
SecondViewController * secondViewController = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
nvc = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[secondViewController release];
[viewControllers addObject:nvc];
[nvc release];
UITabBarController * tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = viewControllers;
[window addSubview:tabBarController.view];
EDIT - Whenever you want to navigate in any one of the controller. All you need is to call
[self.navigationController pushViewController:anotherViewController animated:YES];
And you will get exactly what you want. :)
Upvotes: 2