Why Tabbar Hides After the Segue

Why TabBar hides after the segue?

Your hierarchy should look like this:

* TabBarController
- NavigationController
- ViewController with TableView
- ViewController

Using a Show segue with an UINavigationController pushes the destination view controller onto the navigation stack. However, most other view controllers present the view modally (i.e. by sliding over the source view controller) with Show, which is why your tabbar disappears.

TabBar is hidden after going back to the initial ViewController of a TabBarController Using Segue

When you are using the modal presentation segue, you are creating a completely new instance of HomeViewController. The new HomeViewController is not linked to the TabBarController in your hierarchy.

Here's you initial view hierarchy:

TabBarController
-> HomeVC
-> CreateVC (Navigation Controller)
-> CreateQuizVC
-> SavedVC

Now after tapping the back button you'll get the following:

TabBarController
-> HomeVC
-> CreateVC (Navigation Controller)
-> CreateQuizVC
-> HomeVC(2)
-> SavedVC

What you could do is, instead of using the segue to go back, add an IBAction in your code to set the selectedIndex of the TabBar programatically, and link the Back UIBarButtonItem to this IBAction.

@IBAction func backButtonAction(_ backButton: UIBarButtonItem) {
// Keep in mind that the CreateQuizVC is embeded in a NavigationController.
// The NavigationController is the child of the TabBarController
navigationController?.tabBarController?.selectedIndex = 0
navigationController?.tabBarController?.tabBar.isHidden = false
}

However, my suggestion is you use the TabBar as it's intended by Apple. Don't hide it while you're presenting your CreateQuizVC, and use the TabBar to navigate between the tabs. This will help with user experience, since everybody on iOS is expecting this behaviour from a TabBar.

TabBarController disappears when I segue back to the view from another view

You are following a wrong hierarchy. You are actually using seagues to go back and forth. This creates a new instance every time you try to come back to the first controller.

Let's make it clear:

You need to follow the below approach:

1 You have two controllers A and B.

2 Use self.hidesBottomBarWhenPushed = true in viewDidLoad or viewWillAppear of controller A.

3 Controller A is embedded in a navigation controller which is further embedded in a UITabBarController.

Tapping a button in controller A, you need to push to controller B. So you can use segue for this or you can do it programatically like:

let controllerB = B()
A.navigationController?.pushViewController(controllerB, animated: true)

4 Go Back to Controller A on the tap UIBarButtonItem. So your code in the action of UIBarButtonItem should be something like:

self.navigationController?.popViewController(animated: true)

Remember you should not should segue to go back to the previous controller.

TabBar disappears after Segue (Swift - Xcode)

let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyBoard.instantiateViewController(withIdentifier: "yourTabbarController") as! UITabBarController
self.present(vc, animated: true, completion: nil)

Then:

vc.selectedIndex = indexOfYourTokenVc in tabbar

I hope it may help.

After using a storyboard segue the Tab bar is not showing

Adobels solution is on the right track, I tried it, but it didn't work.
In the end what did the trick was a button on the top right View Controller which did a self.dismiss and then changed the tabbarcontroller selected index.

Here is the function called by a button. (chapter selection button)

@objc func selectChapter(button: UIButton) {
CurrentChapter = button.tag
self.dismiss(animated: false, completion: nil)
if let tabBarController = self.presentingViewController as UITabBarController {
tabBarController.selectedIndex = 1
}
}

Unwind Segue Hides Tab Bar

If I right understand you have storyboard like this:

Sample Image

I don't want to be superficial, but you don't need unwindsegue. If is not like this, post your storyboard to give you the right solution.

Tabbar disappears after segue

Make your TabBarController as InitialViewController and Embed your viewcontrollers with UINavigationController. This will not hide your Tabbar from bottom.



Related Topics



Leave a reply



Submit