iosiphoneswiftuitabbarcontrolleruiviewcontentmode

Transition from UIViewController to TabBarViewController


I have been searching for a solution for 6 hours, and come up with nothing that applies to my situation. my storyboard follows the flow of:

TabBarViewController -> NavigationController ->TableViewController -> UIViewController (see picture below)

Picture of StoryBoard

When the "Notify" button, in the last view controller (Stranger view controller), is clicked, I want to programmatically transition/segue from that View Controller(Stranger View Controller), to a different child of the TabBarViewController (it is the controller titled "Look Around" within the illustration).

Every time I perform a traditional segue:

  1. option + drag segue from Stranger View Controller --> Look Around View controller
  2. Give segue an identifier
  3. programmatically use self.performSegueWithIdentifier.

I get a transition. but the "Look Around" tab bar is gone in the storyboard, and in the simulator, once I hit "Notify", the view changes to the "look around" view, but the tab bar below does not reflect that change, as it still has the previous tab highlighted.

I have already handled all the other processing within the IBAction function that I need to handle. It is just a matter of, correctly, sending the user to a different view, once they have hit "Notify".

Any guidance on this would be greatly appreciated.

If you have any questions or concerns for me, please do not hesitate to ask. I am new at this, and am open to any help.


Solution

  • ViewController is a child of NavigationBar and NavigationBarController is a Child of TabBarController. So Segue is not required as it will disturb the flow.

    Try programmatically

    @IBAction func notifyButtonTapped(sender: AnyObject) {
            tabBarController?.selectedIndex = 1
            tabBarController?.tabBar.hidden = false
            self.navigationController?.popToRootViewControllerAnimated(false)
        }