Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding BarButtons to a UINavigationBar after presenting a modal view controller
    primarykey
    data
    text
    <p>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:</p> <pre><code>navController.viewControllers = [[NSArray arrayWithObject:rootViewController] retain]; [self.view addSubview:navController.view]; </code></pre> <p>I changed the color of the navController just fine:</p> <pre><code>navController.navigationBar.tintColor = [UIColor colorWithRed:0.6 green:0.75 blue:0.6 alpha:1.0]; navController.navigationBar.translucent = NO; </code></pre> <p>I make a button (note: "done" refers to a IBAction that dismisses the modalviewcontroller):</p> <pre><code>UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"TEST" style:UIBarButtonItemStyleDone target:self action:@selector(done:)]; </code></pre> <p>I make a navItem using that button:</p> <pre><code>UINavigationItem *backNavItem = [[UINavigationItem alloc] initWithTitle:@"TESTTEST"]; [backNavItem setRightBarButtonItem:backButton animated:YES]; </code></pre> <p>I try to add that button:</p> <pre><code>[navController.navigationBar pushNavigationItem:backNavItem animated:YES]; </code></pre> <p>This above code fails miserably. I apparently can't add buttons to the navController because:</p> <blockquote> <p>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot call pushNavigationItem:animated: directly on a UINavigationBar managed by a controller.'</p> </blockquote> <p>Do I have to make a separate UINavigationBar that's somehow connected to my navController? I tried going that route but with no avail.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload