Adding BarButtons to a UINavigationBar after presenting a modal view controller

I'm using the template for a utility Application. In the FlipSideViewController, I added an IBOutlet for a UINavigationController, navController. In the code, I added the navController just fine. The rootViewController loads perfectly:

navController.viewControllers = [[NSArray arrayWithObject:rootViewController] retain];
[self.view addSubview:navController.view];

I changed the color of the navController just fine:

navController.navigationBar.tintColor = [UIColor colorWithRed:0.6 green:0.75 blue:0.6 alpha:1.0];
navController.navigationBar.translucent = NO;

I make a button (note: "done" refers to a IBAction that dismisses the modalviewcontroller):

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"TEST" style:UIBarButtonItemStyleDone target:self action:@selector(done:)];

I make a navItem using that button:

UINavigationItem *backNavItem = [[UINavigationItem alloc] initWithTitle:@"TESTTEST"];
[backNavItem setRightBarButtonItem:backButton animated:YES];

I try to add that button:

[navController.navigationBar pushNavigationItem:backNavItem animated:YES];

This above code fails miserably. I apparently can't add buttons to the navController because:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot call pushNavigationItem:animated: directly on a UINavigationBar managed by a controller.'

Do I have to make a separate UINavigationBar that's somehow connected to my navController? I tried going that route but with no avail.

Answers


I checked out "NavBar" here:

Excellent insight on how to do add buttons. You have to add buttons from the correct ViewController being displayed.


Need Your Help

Laravel db not seeding because a Model that extends Eloquent has a constructor...?

php laravel laravel-4

So I have a simple seeder that simply has User::create(array(...)) but it will not seed because my base model has a constructor:

Call PHP method with Ajax.Request

php javascript prototypejs

Whats the best way to call a certain method in a PHP file with Ajax.Request (using prototype)? I am submiting a form with Form.serialize, so I thought of adding a parameter (like the name of the me...