skip to Main Content

My app starts off with a Tab Bar Controller on the first screen after logging in:

enter image description here

Later on the user can tap to get back to that screen, by pressing the Home button. The code for that is:

self.present(self.mealPlanViewController, animated: true, completion: nil)

The issue is that when they go back to that view controller, the Tab Bar is no longer there.

enter image description here

How can I present the view controller with the Tab Bar again?

2

Answers


  1. Chosen as BEST ANSWER

    I was able to figure it out - please see below:

    1. I added @IBAction func unwindToContainerVC(segue: UIStoryboardSegue) {} to the view controller I wanted to go back to. This added an Action Segue.

    2. I added the segue to the storyboard and gave it the identifier, "unwindToMealPlanViewController"

    3. I added the following code to my Done button: self.performSegue(withIdentifier: "unwindToMealPlanViewController", sender: nil)

    These were some very helpful resources in solving this:


  2. You said:

    "Later on the user can tap to get back to that screen, by pressing the Home button. The code for that is:"

    self.present(self.mealPlanViewController, animated: true, completion: nil)
    

    That is wrong. You are not "getting back" to anything. You are presenting self.mealPlanViewController modally. That means it is being drawn on top over everything else. If self.mealPlanViewController was previously on-screen, bad things may happen.

    In order to help you sort it out, you need to explain your view controller hierarchy and the flow between screens. What is the name of your tab bar controller’s class? Of the view controllers that are displayed as tabs? How are you getting from the tab bar controller to the screen that contains the home button?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search