1
votes

I have UITabBarController with NavigationController. Then i push a child VC onto Navigation controller li this:

    let tabBarController = UITabBarController()
    let navController    = UINavigationController()
    let vc = Registration_VC()

    navController.addChildViewController(vc)
    tabBarController.addChildViewController(navController)
    self.presentViewController(tabBarController, animated: true, completion: nil)

So that works fine. Then I push another VC(same) onto navigation controller from 'Registration_VC()' like this:

        let vc = Registration_VC()
        self.navigationController?.pushViewController(vc, animated: true)

Works fine. However when I touch anywhere on the TabBar the current VC pops. I don't understand why.

1

1 Answers

0
votes

For Swift 2 you have to use the following code to push a new Viewcontroller:

let myViewControllerObejct = self.storyboard?.instantiateViewControllerWithIdentifier("ViewControllerIdentifier") as? myViewController
    self.navigationController?.pushViewController(viewControllerObject!, animated: true)

No addchildviewcontroller needed. I hope this helps