0

I have the following code with adds a navigation controller to a modal view. The nav bar and view all appear ok, but the right button does not. What am I doing wrong?

    UpgradesViewController* upgradesViewController = [[UpgradesViewController alloc] initWithNibName:@"UpgradesView" bundle:nil];
    upgradesViewController.title = @"Upgrades";

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:upgradesViewController];
    navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    navController.navigationBar.barStyle = UIBarStyleBlack;
    UIBarButtonItem* doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Show" style:UIBarButtonItemStylePlain target: self  action:nil];
    navController.navigationItem.rightBarButtonItem = doneButton;
    [self presentModalViewController:navController animated:YES];

    [navController release];
    [upgradesViewController release];
Aeolai
  • 199
  • 1
  • 12

1 Answers1

10

Add doneButton to the navigationItem of upgradesViewController, not to navController. The navigation controller displays the navigation item of the top controller, not itself.

drawnonward
  • 53,459
  • 16
  • 107
  • 112
  • 1
    Then you should accept the answer so that he gets points (and so that people will continue to answer your questions in the future). – cduhn May 22 '10 at 02:11