我有以下代码,将导航控制器添加到模态视图中。导航栏和视图都显示正常,但右键不显示。我做错了什么?
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 :(得分:10)
将doneButton添加到upgradesViewController的navigationItem,而不是navController。导航控制器显示顶部控制器的导航项,而不是其自身。