UINavigationItem's title disappears when view controller is pushed

1.2k Views Asked by At

I am having an issue with my view controller's navigation item's title. Indeed, I am setting it in the viewDidLoad method like this :

self.navigationItem.title = "Title"

The problem is that when I push this view controller from another on to the navigation stack, I see the title while the transition but as soon as the transition ends, it disappears... I checked in the debugger, the title is still set... I tried with the titleView property either with no success... By the way, the problem only show up on iPhone 5 with iOs < 9...

1

There are 1 best solutions below

3
GlennRay On

Let's try that as an answer: CGSize result = [[UIScreen mainScreen] bounds].size; _navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0, result.size.width, 40)]; _navItem = [[UINavigationItem alloc] initWithTitle:@"Title"]; [_navBar setItems:@[_navItem]]; [self.view addSubview:_navBar];