Can't get a simple title to display


#1

Well, with two hours of my life down that I’ll never get back…

I was playing around with the following code and the title will not show up in my app:

in appdelegate.m

JCGRootNavigationController *rnc = [[JCGRootNavigationController alloc] init]; self.window.rootViewController = rnc;

in my JCGRootNavigationController.h file:

[code]#import <Foundation/Foundation.h>

@interface JCGRootNavigationController : UINavigationController

@end[/code]

in my JCGRootNavigationController.m file:

[code]#import “JCGRootNavigationController.h”

@implementation JCGRootNavigationController

-(instancetype) init {

self = [super init];
if (self) {
    self.view.backgroundColor = [UIColor lightGrayColor];
    self.navigationItem.title = @"My Title";
}

return self;

}[/code]

the lightGray color displays but not the title. Any ideas?


#2

What you want to do is set the title of your ItemsViewController. Then it should display in the navigation block at the top:

[code] // create an items View Controller which will eventually be the root VC for the NAV_VC
CPEItemsViewController *ivc = [[CPEItemsViewController alloc] init];

// create a NAV-VC
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:ivc];
ivc.title = @"Homepwner App";

// place the NAV-VC in the window hierarchy
self.window.rootViewController = navVC;

[/code]


#3

Hey, that worked. Thanks much.