How to add a button to a UINavigationController

I have the following code with the addition of a navigation controller to a modal view. The navigation bar and everything looks fine, but not on the right button. 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]; 
0
source share
1 answer

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

+10
source

Source: https://habr.com/ru/post/911514/


All Articles