2

I am not sure what's going wrong with my UINavigationBar title things. I am not able to get it working after trying all possible things. The navigation bar appears but title is missing!! Here is my simple code,

self.marketsListViewController = [[MarketsListViewController alloc] initWithNibName:@"MarketsListViewController" bundle:nil];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:self.marketsListViewController];
nvc.navigationBar.barStyle = UIBarStyleBlack;
[self.marketsListView addSubview:nvc.view];
[self addChildViewController:nvc];
[nvc didMoveToParentViewController:self];

In MarketsListViewController's didViewLoad, I have tried all of following and none of them worked!!! Could someone please help me to understand what's going on? Thanks.

self.title = @"MyTitle";
self.navigationItem.title = @"MyTitle";
self.navigationController.navigationItem.title = @"MyTitle";
Paresh Masani
  • 7,474
  • 12
  • 73
  • 139

1 Answers1

1

There seem to be some changes in UINavigationController from iOS6.

https://stackoverflow.com/a/13205842/1171003

When I wrote code like this, the title was not shown at all.

UITabBarController *tb = [[UITabBarController alloc] init];
tb.viewControllers = [NSArray arrayWithObjects:
                       [[ViewController1 alloc] init],
                       [[ViewController2 alloc] init],
                       nil];

UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:tb];

However, after I added this line, it appeared.

tb.title = @"Title";
Community
  • 1
  • 1