[英]can't set right button of UITabBarController's moreNavigationController
I'm having a very strange problem where I can set all properties of a UITabBarController's moreNavigationController except for the rightBarButtonItem property. 我遇到一个非常奇怪的问题,我可以设置UITabBarController的moreNavigationController的所有属性(rightBarButtonItem属性除外)。 I'm guessing it might be because of some bug relating to the customizableViewControllers property disabling all right bar button items. 我猜这可能是由于与customizableViewControllers属性相关的一些错误,该错误禁用了所有右栏按钮项。 Any ideas how to fix? 任何想法如何解决?
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
Ok the solution was to use the delegate of moreNavigationController 确定的解决方案是使用moreNavigationController的委托
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *) viewController animated:(BOOL)animated {
viewController.navigationItem.rightBarButtonItem = doneButton;
}
Paludis, thanks a lot! Paludis,非常感谢! This is a fix for now. 现在是修复程序。
func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {
//More navigation controller Bug. The rightBarButton item disappears on pop, in case this is MoreNavControl
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Add, target: self, action: "createProject")
}
override func viewDidLoad() {
super.viewDidLoad()
if (self.navigationController == self.tabBarController?.moreNavigationController)
{
self.navigationController?.delegate = self
}
else
{
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Add, target: self, action: "createProject")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.