Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
527 views
in Technique[技术] by (71.8m points)

ios - Keep TabBar when moving to another view controller

I have a storyboard like this

-> NavigationController -> LoginView -> TabBarController -> VC1 -> VC2

I didn't manage to make a "move" from VC1 to VC2 keeping the tab bar.

I tried the followings :

  • Segue (Show type)

    self.performSegueWithIdentifier("toVC2segue", sender: self)
    
  • instantiate programmaticaly :

    // prepare for future display
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let navigationVC = UIApplication.sharedApplication().keyWindow?.rootViewController as! UINavigationController
    
    // prepare next view
    let vc = storyboard.instantiateViewControllerWithIdentifier("VC2id")
    
    self.tabBarController?.navigationController?.pushViewController(vc, animated: true)
    

but both make the tab bar disappearing.

I tried also

self.hidesBottomBarWhenPushed = false

but this didn't change anything.

Do you have another idea ?

PS : I updated my scheme above...

Edit : After reading the answers below, I tried to add another navigation controller :

-> NavigationController -> LoginView -> TabBarController -> NavigationController -> VC1 -> VC2

but I have now 2 navigation bars superposed in VC1 and VC2...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your view hierarchy should not look like this if you want to keep the tabBar.

-> NavigationController -> TabBarController -> VC1 -> VC2

You should change it to -> TabBarController -> NavigationController -> VC1 -> VC2


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...