0

I'm trying to programmatically change the view in the navigation controller which is inside a tab controller. I defined a UINavigationController and made it to be the class for that navigation controller view. In the viewDidAppear method I tried to do performSequeWithIdentifier but it does not work. Please help to do this.

class ABCNavigationController: UINavigationController
{   
    override func viewDidAppear(animated: Bool) {
        self.performSegueWithIdentifier("MySegue", sender: self)
    }
}

Thanks, Ruben

rubenhak
  • 830
  • 2
  • 10
  • 28

1 Answers1

0

Segues only exists with interface builder. So if you are working on an app purely programatically you unfortunately can't use segues.

Instead I use this:

func nextViewController() {
    var VC = nameOfNextViewController()
    self.navigationController?.pushViewController(VC, animated: true)
}

This pushes the next view to your navigation stack, when the function "nextViewController" is called.

MLyck
  • 4,959
  • 13
  • 43
  • 74
  • Well, that's not completely true. I was able to call segues from the code but the view appears on top of the tab control. What i want is the programmatically selected view controller to appear within the tab. I tried your approach as well. It does not work because the self.navigationController is nil. – rubenhak Mar 24 '15 at 16:57