3

I combine tabbarcontroller with navigationcontroller. I set navigationitem title by using,

self.tabBarController?.navigationItem.title = "first"

for first page

self.tabBarController?.navigationItem.title = "second"

for second page,and the title showed.

But when I switch to second page, and switch back to first page, the title still display as second.It doesn't changed back to first.

How can i fix it?

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
evelyn
  • 45
  • 8

2 Answers2

0

Try to set title in your view Controller's viewDidLoad Method as following :

self.navigationItem.title = "First Page" // in First Page ViewController

self.navigationItem.title = "Second Page" // in Second Page View Controller

So that whenever you're switching to other viewcontrollers, the title will set accordingly..

Hope it helps..

Balaji Ramakrishnan
  • 1,909
  • 11
  • 22
0

Try to set title in your view Controller's viewDidAppear Method

func viewDidAppear(animated: Bool)
{
    self.tabBarController?.navigationItem.title = "first" 
}

for first page

func viewDidAppear(animated: Bool)
{
    self.tabBarController?.navigationItem.title = "second" 
}

for second page

Jayesh Miruliya
  • 3,279
  • 2
  • 25
  • 22