<-

UINavigationController With Toolbar

The confounding thing about this for me is that the toolbar is a part of the NavigationController, but access to the toolbar pointer and, consequently the tool bar items, is through the viewController that is currently loaded into the NavController.

I did not see this explicitly called out anywhere, so I feel a little concerned that I have it wrong, but it is clearly how you do this both in .xib's and programmatically.

and you see that if you push a new VC class, that the toolbar is empty of buttons again.

Programmatically:

AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor redColor];

CBFViewController *viewC = [[CBFViewController alloc] init];

UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:viewC]; navC.toolbarHidden = NO;

self.window.rootViewController = navC;

[self.window makeKeyAndVisible];

return YES; }

VC ViewDidLoad:

self.view.backgroundColor = [UIColor greenColor];

UIBarButtonItem *bOne = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(one:)]; UIBarButtonItem *bTwo = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(two:)]; UIBarButtonItem *bThree = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPause target:self action:@selector(three:)]; UIBarButtonItem *flex1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(three:)]; UIBarButtonItem *flex2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(three:)];

self.toolbarItems = @[bOne, flex1, bTwo, flex2,bThree];

push a new VC

- (void)one:(id)sender { CBFViewController2 *two = [[CBFViewController2 alloc] init];

[self.navigationController pushViewController:two animated:YES]; }