IOS app with navigation bar and navigation controller

In the fight against creating my first iPhone app, I noticed that Apple examples have a navigation bar or panel, but never both.

Can this be done?

So I have a panel with three buttons, how can I add a navigation controller to my entire application?

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

UIViewController *activityViewController = [[[ActivityViewController alloc] initWithNibName:@"ActivityViewController" bundle:nil] autorelease];
UIViewController *agendaViewController = [[[AgendaViewController alloc] initWithNibName:@"AgendaViewController" bundle:nil] autorelease];
UIViewController *settingsViewController = [[[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil] autorelease];

self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:activityViewController, agendaViewController, settingsViewController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];

EDIT:

I really don't follow, so in my appdelegate I created a navigation controller and used it as rootViewController.

Then I created a tabBarController and added it to my window

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

UINavigationController *mainViewController = [[UINavigationController alloc] init];
self.mainViewController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
self.window.rootViewController = self.mainViewController;
[self.window makeKeyAndVisible];

self.window.rootViewController.title = @"test";

MainViewController *tabBarController = [[MainViewController alloc] init];
[self.window addSubview:tabBarController.view];

But whenever I start, I get an error

Pressing the navigation controller is not supported

Am I still missing something?

+3
source share
2 answers

, tabBarController ,

 //incase you have 2 navigation controllers
 tabBarController.viewControllers=[NSArray arrayWithObjects:navigationController1, navigationController2, nil ];
0

, :

rootViewController , .

YourRootController *cont = [[YourRootController alloc] init];

UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:cont];

YourViewController UITabBarController

.

0

All Articles