Arian Faurtosh Arian Faurtosh - 1 year ago 66
iOS Question

self.title and nav bar not working in iOS 7

For some reason, when I used to just have

self.title = @"Title";

to get the title bar to show up... but now in iOS 7 it won't show anything.

I've been working on this for about 2 hours... and I can't even get the title bar up and running.

I've also tried

self.navigationController.navigationBar.topItem.title = @"Title";
self.navigationItem.title = @"Title";

none of the above work.

Here is my code:

- (void)viewDidLoad
[super viewDidLoad];
self.title = @"Title";
self.navigationItem.title = @"Title";
self.navigationController.navigationBar.topItem.title = @"Title";
// Do any additional setup after loading the view.

I don't know what else to try, I just downloaded the latest version of iOS 7/Xcode and I used the tab template.

I am really new to Xcode so I don't really know what i am doing.

Edit, more info below:

First Images

Second Images

Third Images

Fourth Images

Fifth Images

Answer Source

All you have done is set the "simulated metrics". That's all that does: it simulates the navigation bar. It doesn't actually give you a navigation bar. You're saying you don't need to actually navigate, so you don't need a navigation controller. Although that's a perfectly fine approach, a navigation controller comes with more perks. For example, setting self.title will not work with a standalone navigation bar, but a navigation controller sets its navigation bar's title to whatever self.title is.

So, in your case, I would simply embed your view controller in a navigation controller, even if you're not using any of the actual navigation features.