我想在我的导航栏中
添加一个默认的左栏按钮项.只有当UINavigationController没有提供后退按钮时才应该
显示.
什么是最好的方法?
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if(navigationController.viewControllers.count != 1) { // not the root controller - show back button instead
return;
}
UIBarButtonItem *menuItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
target:self
action:@selector(menuItemSelected:)];
[viewController.navigationItem setLeftBarButtonItem:menuItem];
}
原文链接:https://www.f2er.com/iOS/336067.html