是否可以从视图的NIB中设置navigationitem.title? [英] Is it possible to set navigationitem.title from a view's NIB?

查看:79
本文介绍了是否可以从视图的NIB中设置navigationitem.title?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从NIB(initWithNibName)加载一个新视图然后我将它推入导航控制器堆栈(pushViewController)。

I am loading a new view from a NIB (initWithNibName) and then I am pushing it into navigation controller stack (pushViewController).

为了有一个合适的后退按钮每个视图都应该有一个标题。
遗憾的是,我没有找到在Interface Builder中设置View Title的方法。

In order to have a proper "Back" button each view should have a title. Unfortunately I didn't manage to find a way to set up View Title in the Interface Builder.

可以在运行时完成:

- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"MyTitle";  
}

但我没有设法在NIB的设计时间内完成。

But I didn't manage to do it in design time in the NIB.

有办法吗?

谢谢。

我刚刚意识到我的问题不是100%正确。

I just realised my question is not 100% correct.

事实上我正在寻找一个通过NIB设置ViewController标题的方法。

In fact I am looking for a way to set ViewController's title via NIB.

NIB中的UIView与UIViewController(获取我想要更改的title属性)不同。

And UIView in the NIB is different from the UIViewController (which got the title property I am trying to change).

所以我的问题是......关于不同的事情。 :)

So my question was ... about something different. :)

推荐答案

您应该能够通过导航控制器项访问根视图控制器的导航项。根视图控制器的导航项具有您可以在IB中访问的属性标题。

You should be able to access the root view controller's navigation item through the navigation controller item. The root view controller's navigation item has the property title that you can access in IB.

也许这张图片有帮助(您基本上点击蓝色导航栏将焦点放在导航项目):

maybe this picture helps (your basically clicking on the blue navigation bar to put focus on the navigation item):

这篇关于是否可以从视图的NIB中设置navigationitem.title?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆