我遇到一个非常奇怪的问题,我可以设置UITabBarController的moreNavigationController的所有属性(rightBarButtonItem属性除外)。我猜这可能是由于与customizableViewControllers属性相关的一些错误,该属性禁用了所有右栏按钮项。任何想法如何解决?
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(popViewController)];
self.customizableViewControllers = nil;
self.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;
self.moreNavigationController.topViewController.navigationItem.title = @"test"; //this works
self.moreNavigationController.topViewController.navigationItem.leftBarButtonItem = doneButton; // this works
self.moreNavigationController.topViewController.navigationItem.rightBarButtonItem = doneButton; // this doesn't
最佳答案
确定的解决方案是使用moreNavigationController的委托
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *) viewController animated:(BOOL)animated {
viewController.navigationItem.rightBarButtonItem = doneButton;
}