Simple Title not showing up in UINavigationController

I have looked at all of the similar/related questions, but none either a) are exactly my problem or 2) the solutions just don’t work.

In my appDelegate.m I have in didFinishLaunchingWithOptions

  • Really cool way to create custom UITabBar for iPhone app?
  • Remove mask from deselected tabs UITabBarItem Swift
  • Changing tab bar item image and text color iOS
  • Is there anyway to add same scroll menubar at the navigation bar?
  • Change tab bar item selected color in a storyboard
  • iOS : How to add Underline in UITabBarItem
  • JCGRootNavigationController *rnc = [[JCGRootNavigationController alloc] init];
    self.window.rootViewController = rnc;`
    

    JCGRootNavigationController is a subclass of UINavigationController

    @interface JCGRootNavigationController : UINavigationController`
    

    In JCGRootNavigationController.m:

    @implementation JCGRootNavigationController
    
    -(instancetype) init {
        self = [super init];
        self.view.backgroundColor = [UIColor lightGrayColor];
        self.navigationItem.title = @"MY TITLE";    
        return self;
    }
    

    And the title just won’t display. I see the Navigation Bar, but no title. Looks like lots of people over the years have had this same problem. Maybe a simple answer will help clear up all of the confusing. This is so incredibly frustrating.

    3 Solutions Collect From Internet About “Simple Title not showing up in UINavigationController”

    UINavigationController automatically shows the title of the UIViewController subclass it is displaying. It does so by looking at the navigationItem.title property of that UIViewController or UIViewController subclass. Basically UINavigationController doesn’t have a title.

    When working with a Storyboard, setting the title of the UIViewController or UITableViewController does not seem to add that title to the Navigation Controller, as other answers suggest.

    Instead, find the UINavigationItem that is likely alongside your View Controller object in the Storyboard panel. Set this Navigation Item’s title to apply that title to the Navigation Controller.

    Navigation Item on Storyboard[1]

    Thanks believesInSanta, While I cannot find this explicitly stated in apple documentation anywhere, I have to go with this being the answer. UINavigationController doesn’t have a title.

    To get the title to work, back in appDelegate.h I added:

    JCGTableViewController *tvc = [[JCGTableViewController alloc] init];
    JCGRootNavigationController *rnc = [[JCGRootNavigationController alloc] initWithRootViewController:tvc];
    self.window.rootViewController = rnc;
    

    Where JCGTableViewController is another subclass I added. As you can probably tell, it is a subclass of UITableViewController.

    In JCGTableViewController I overrode init to:

    -(instancetype) init {
    
        self = [super init];
        if(self) {
            self.title = @"TVC";
            self.view.backgroundColor = [UIColor lightGrayColor];
        }
    
        return self;
    }
    

    While I used a tableViewController, I imagine you can add any view to the NavigationController and set the properties that way. I will play around with that today.

    Thanks all!