开发者

Is it possible to set navigationitem.title from a view's NIB?

开发者 https://www.devze.com 2023-04-05 08:24 出处:网络
I am loading a new view from a NIB (initWithNibName) and then I am pushing it into navigation controller stack (pushViewController).

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

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.

It can be done in run time:

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

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

Is there a way of doing it?

Thank you.


I just realised my question is not 100% correct.

In fact I am looking for开发者_运维知识库 a way to set ViewController's title via NIB.

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. :)


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):

Is it possible to set navigationitem.title from a view's NIB?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号