下面的 mwthod 是 UINavigationController 的委托方法。我想成为 abel 来决定是否将左侧项目添加到每个页面。下面的代码不起作用,我做错了吗?
我不想通过 ViewController 本身来执行此操作。我希望 NavigationCopntroller 负责这项任务。
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UIBarButtonItem *menuItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
target:self
action:@selector(menuItemSelected:)];
[self.navigationItem setLeftBarButtonItem:menuItem];
// I also tried
// [viewController.navigationItem setLeftBarButtonItem:menuItem];
}