0

I have a Tab bar in the first view and a total of two views.

However, when I move from the first view to the second view and then back to the first view using the Segue, the Tab bar of the first view disappears.

When return to the first view from the second view, what is the way the Tab bar does not disappear?(without using unwind)

enter image description here

Bappaditya
  • 9,494
  • 3
  • 20
  • 29
dinggu
  • 111
  • 7

3 Answers3

1

Don't use unwind segue here. When you need to get back to previous ViewController, just dismiss your current ViewController

dismiss(animated: true, completion: nil) /* call this in second VC */
Robert Dresler
  • 10,580
  • 2
  • 22
  • 40
1

I suggest you read the documentation for understanding how combined View Controller Interfaces. Anyway, if you need to pop to previous view controller on the flow, you need to use

navController.popViewController(animated: true)

But, if the need to pop up on the specific ViewController on the queue of View Controllers in the NavigationViewController, you need to use

 navController.popToViewController(ViewController, animated: true)

From the moment you are using a NavigationController, a return button will automatically appear on the UINavigationBar, so you do not have to worry about that. Unless you want to customize the back buttons in the viewcontrollers queue, in this case use the above methods.

Tarek Jradi
  • 101
  • 7
  • Where do you see `UINavigationController` in his question? Anyway, from ViewController you can get reference to current NavController using `navigationController` property – Robert Dresler Dec 28 '18 at 09:57
0

It's for page 1. Display tabBarController once page is loaded.

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    self.tabBarController?.tabBar.hidden = true
} 

If click event is fired, hide tabBarController.

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
    if (segue.identifier == "twoSegue") {
        self.tabBarController?.tabBar.hidden = false
    }
}
PPShein
  • 13,309
  • 42
  • 142
  • 227