1

I come across a strange issue

code :

- (void) viewDidLoad 
{
    [super viewDidLoad];
    self.navigationItem.title = @"Hello title";
}

and there is a navigation bar in the xib file. the navigtion bar is show in the view after loaded. however, "Hello title" does not show in the navigationbar.

so How can I change the navigationbar title ?

thanks a lot!

explorer
  • 449
  • 2
  • 10
  • 19

4 Answers4

10

Try out this piece of code:

  self.navigationController.navigationBar.topItem.title = @"The Title";
mikemike396
  • 2,435
  • 1
  • 26
  • 41
arniotaki
  • 101
  • 1
  • 3
  • For swift I had to add two exclamation points self.navigationController!.navigationBar.topItem!.title = "The Title"; – SlopTonio Jul 16 '15 at 11:21
0

Try this

self.title = @"Hello title";
Neo
  • 2,807
  • 1
  • 16
  • 18
0

type this on view didload which where you the view' navigation self.title = @"Hello title";

fazil
  • 57
  • 1
  • 8
-2

Try writing tis in viewDidLoad method:

self.navigationItem.titleView=[self navigationItemTile:@"Hello Title"];

Or try in the initWithNibname method:

[self setTitle:@"Hello title"];
Anne
  • 26,765
  • 9
  • 65
  • 71
Ramya
  • 123
  • 6