Why Is the Tab Bar Disappearing

Why is the tab bar disappearing?

I had a similar problem and the right question was kind of hard to ask. using Tsb Bar Controllers with Navigation Controllers and View Controllers os too tricky and certain things a re not allowed and there is a lot of terminology, and, there are many different types of segues,and there are many different kinds of consequences for doing certain things.

I found the correct procedure (answer) in the second part of this two part series:

  1. Storyboards Tutorial for iOS: Part 1
  2. Storyboards Tutorial for iOS: Part 2

Summary of the procedure:
Embed the source and destination View Controllers in Navigation Controllers, then create unwind segues (methods with the signature@IBAction func methodname(_ segue:)) in the source view controller. Then, from the destination View Controller, control-click from the navigation bar button (or any view required to trigger a return to the first view controller) to the Exit object above the view controller then pick the correct action name from the popup menu. The unwind segue will be accessible from the Document Outline and can be given an identifier to use in prepare(for:sender:) in case data needs to be sent to the from the destination view controller. Also, the segue from the first view Controller to the second navigation controller must be modal.

My tab bar and navigation controller disappears when i register for account

I should see the full Storyboard logic to give you a better answer, but I think your answer will be somewhere the presentation style.
NOTE: Only a suggestion, but your view hierarchy should be reviewed, because when you log in your homeviewcontoller(you can "pop" back, or you can replace the whole viewstack) should be your rootviewcontroller, and if I understand correctly there is a stack when you click through login. But here is a possible quick fix:

homeVC.modalPresentationStyle = .currentContext

If it does not help, one of these will:
https://developer.apple.com/documentation/uikit/uimodalpresentationstyle

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.

Tab bar and Navigation bar disappeared when navigate from Appdelegate

Select ViewController from the storyboard.

Go to the Editor and Embed with Navigation Controller or Tab Bar Controller

Sample Image

Give Storyboard ID to your Navigation Controller or Tab Bar Controller

Sample Image

Assign that Navigation Controller or Tab Bar Controller to Root Viewcontroller from AppDelegate.

let storyBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let Root_Vc = storyBoard.instantiateViewController(withIdentifier: "RootVc")
self.window?.rootViewController?.present(Root_Vc, animated: true, completion: nil)

Tab Bar Controller disappearing when moving back to another view

I have solved my problem after days of trying to figure out an answer. You need to add this to any view controller.

@IBAction func unwindToViewController (sender: UIStoryboardSegue){

}

Then you can add a segue from bar button item to the exit icon on the view controller.

You can view an image of the VC scene here.



Related Topics



Leave a reply



Submit