Search code examples
iosobjective-cnavigationbarpushviewcontrollertitlebar

iOS 10 - View Controller / Navigation Bar Title hidden


I'm currently facing stranges behaviours with iOS 10.

Indeed, everything was working fine, but since I updated to xCode 8 and began testing my App on iOS 10, a lot of stuff went wrong.

For example, all my Navigation Bar's titles are not displayed anymore.

More precisely, when I'm using the menu to navigate threw my app, every time I switch to a different view, there are no title, BUT when I press the back button, I can briefly see it before the transition to the other view.
I don't understand this new behaviour, I didn't change anything in the code, and when I launch the App on iOS 9 or lesser, everything is working properly.

I tried to set the title in the ViewWillAppear / ViewDidLoad, in the prepareForSegue, but nothing is working.

if ([segue.identifier isEqualToString:kMy_Segue]) {
    MyViewController* destinationVC = segue.destinationViewController;
    [destinationVC setTitle:@"MyTitle"];
}

I feel like there are some changes with the pushed Navigation Controller, or the title item is not at the same index than the Navigation Bar itself because when I navigate threw subviews in the menu, the title only appears when I press back.

For example I have a category in my Menu called "World". When I tap it I want the title of the subview to be "World", but nothing is displayed. Then, I have all the continents listed "Africa", "Europe", "Asia" etc... When I tap on Africa, I want the next title to be "Africa" right? And again, nothing is displayed BUT if I press the back button and go back to the list of continents, the title "World" appears.

If anyone has encountered this issue, I would really appreciate some help.


Solution

  • Follow this:

    Solution-1

    Goto to the viewController, then click on NavigationItem as shown below:

    enter image description here

    In the right pane, change "Title" as follows:

    enter image description here

    Solution-2

    Add a UIView to your navigationBar as shown below:

    enter image description here

    Add an UILabel to your navigationItem as shown below:

    enter image description here

    Change the frame of the newly added UILabel as follows:

    enter image description here

    Change text of UILabel to "Sample Title" and change UIView backgroundColor to clearColor.

    I have made a sample in Xcode8, please check my GitHub link below:

    https://github.com/k-sathireddy/NavigationItemSample