简体   繁体   English

无法设置UITabBarController的moreNavigationController的右键

[英]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.

相关问题 编辑按钮未显示在UITabBarController的MoreNavigationController中 - Edit button not displayed in UITabBarController's MoreNavigationController 自定义UITabBarController的moreNavigationController - Customizing UITabBarController's moreNavigationController 更改UITabBarController的moreNavigationController中的“编辑”按钮颜色? - Change 'edit' Button Color from moreNavigationController of UITabBarController? UINavigationController在UITabBarController的moreNavigationController中不起作用 - UINavigationController doesn't work in a the moreNavigationController of a UITabBarController 单击导航栏上的按钮以进行操作更多的NavigationController —无法pushviewcontroller - Act on click of a button on the Nav Bar for moreNavigationController — Can't pushviewcontroller UITabbarController与MoreNavigationController,PoptoRootViewController问题 - UITabbarController with MoreNavigationController , PoptoRootViewController issue UITabBarController.moreNavigationController禁用项目 - UITabBarController.moreNavigationController disable items UITabBarController 设置选中的 MORE BUTTON - UITabBarController set selected MORE BUTTON 如何在UITabBarController中的UINavigationController中添加右键? - How to add a right button to a UINavigationController in a UITabBarController? 更改moreNavigationController图标的颜色 - Change the color of moreNavigationController's icons
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM