开发者

How to add button to UINavigationController

开发者 https://www.devze.com 2022-12-31 23:51 出处:网络
I have the following code with adds a navigation controller to a modal view. The nav bar and view all appe开发者_JAVA技巧ar ok, but the right button does not.What am I doing wrong?

I have the following code with adds a navigation controller to a modal view. The nav bar and view all appe开发者_JAVA技巧ar 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];


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

0

精彩评论

暂无评论...
验证码 换一张
取 消