iphone - 无法设置UITabBarController的moreNavigationController的右键

标签 iphone objective-c ios

我遇到了一个非常奇怪的问题,我可以设置 UITabBarController 的 moreNavigationController 的所有属性(除了 rightBarButtonItem 属性)。我猜这可能是因为与可定制 View Controller 属性相关的一些错误禁用了所有右栏按钮项目。有什么解决办法吗?

    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 的委托(delegate)

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *) viewController animated:(BOOL)animated {

viewController.navigationItem.rightBarButtonItem = doneButton;

}

关于iphone - 无法设置UITabBarController的moreNavigationController的右键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5325827/

相关文章:

ios - 如何在 UIStackView 中排列的 subview 上设置自定义高度?

首次 Facebook Connect 授权/登录后 iPhone 应用程序崩溃

iphone - 我怎样才能用翻译实现字典

ios - 无法为 uialertview 设置标签

ios - 获取uiview的主色、副色、三级颜色

iphone - 解析时的内存问题

ios - 在 viewDidLoad() 中使用 CLLocationManager() 可以防止 MKMapView 被拖动或缩放

iphone - 沿着简单的三次贝塞尔曲线找到给定距离的点。 (在 iPhone 上!)

iphone - 在 Xcode 中设置 RestKit

objective-c - Xcode 4 Interface Building字体未更新/显示