Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationController TitleView not displayed from ViewController NavigationItem

Whenever I add a viewController to a navigationController while in landscape the title view appears on certain views but not on others. ie: I have a navigation controller, add 3 view controllers, first two show titleview appropriately, third one doesn't show one at all. But the navigation controller grabs the titleview from the ViewController like it's supposed to, I wrote the value of it to the console and it is correct, but it just doesn't show on the screen for whatever reason. Any ideas?

Oh yeah works perfectly while in portrait orientation.

Here's another fun part, if I push the trouble view controller into the navigationController in landscape the titleView isn't there, then without any user interaction, I rotate the device back to portrait and the titleView appears, then I rotate the device back to landscape and it stays!

It's like the drawing of my TitleView was blocked even though I used InvokeOnMainThread. Nothing is running in the main thread (or anywhere for that matter) during that call.

Here's my structure:

Window
  TabBarController 
    NavigationController 
      ViewController
    NavigationController
      ViewController

Here's my order of operations:

  1. Create View Controller
  2. Add Title view to view controller
  3. Push View Controller onto NavigationController (InvokeOnMainThread)
like image 857
Chuck Pinkert Avatar asked Oct 11 '22 10:10

Chuck Pinkert


1 Answers

Have you tried setting the controller title after the controller is pushed? This kind of behavior happens to me and the way to make sure the title appears is to mandatory set the navBar title in the viewDidLoad or viewWillAppear method as follows:

self.navigationController.navigationBar.topItem.title = @"The title";

or

self.navigationItem.title = @"The Title";

Other thing that happened to me is to set the leftBarButton or RightBarButton of a navigation bar without success in the viewDidLoad method, but they appear correctly when setting the bar buttons in the viewWillAppear method.

Hope this helps.

like image 163
Omer Avatar answered Oct 13 '22 01:10

Omer