ios - Storyboard导航 Controller 和标签栏 Controller

标签 ios uinavigationcontroller storyboard uitabbarcontroller uistoryboard

我正在尝试在 Storyboard 中进行以下设置。

Storyboard

我一开始有一个表格 View ,当我点击一个单元格时,它需要转换到标签栏 Controller ,这是可行的。但是现在我想要在最右边的两个 Controller 中有一个标题和一个额外的导航栏按钮。

但我似乎无法将按钮拖到那里,或者在设置标题时,什么也没有显示。如何在 Storyboard 中实现此设置?


根据以下答案更新了问题。

New setup

当我有了这个新设置(因此中间有一个额外的导航 Controller )时,我可以在 Storyboard 中设置标题,但是在运行应用程序时,添加的标题不会显示。

我有uploaded具有完全相同设置的 Xcode 项目。也许它能派上用场。

最佳答案

要更改 UINavigationBar 标题(无需创建其他 2 个 UINavigationController),您只需使用

[self.parentViewController.navigationItem setTitle:@"Title"];

添加右键使用

self.parentViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(myRightButton)];

viewDidLoad 方法上为从您的 UITabBarController 引用的每个 UIViewController

如果您想在 TabItemsUIViewController 中使用“导航结构”,那么您可以将 BUFViewController.m 编辑为:

#import "BUFViewController.h"

@interface BUFViewController ()

@end

@implementation BUFViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self.parentViewController.navigationController setNavigationBarHidden:YES];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
}

-(void)done{
    [self.parentViewController.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

您必须认为您的 UITabBarController 位于您的父级 NavigationController 中,因此您想隐藏父级 UINavigationBar 并显示您的父级。 之后,您将能够使用 popToRootViewControllerAnimated 返回您的表格:在父级的 UINavigationController 上。

希望对您有所帮助:)

关于ios - Storyboard导航 Controller 和标签栏 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23548088/

相关文章:

ios - 不同节点上多个 SKAction 的完成 block

ios - 验证/提交错误 : Application failed codesign verification

ios - 从 presentModalViewController 推送 uiviewcontroller

objective-c - 为什么我的 UINavigationController 右键加载后就消失了

ios - 通过 Xcode 中的源代码管理将 Storyboard 提交到 SVN

ios - 如何在swift 3中使用Delete方法从Json获取数据?

ios - Payway 集成到 iPhone 应用程序的教程?

iphone - 在导航栏中添加多个按钮

ios - objective-c - IB - 垂直居中 3 多行 UILabels

ios - 如何在继续之前更新应用程序