Swift presentViewController

后端 未结 13 2005
悲&欢浪女
悲&欢浪女 2020-11-30 21:25

I programatically have multiple View Controllers in an iOS Swift Project. I do not have the storyboards and would like to avoid them if possible. Is there a way to switch to

相关标签:
13条回答
  • 2020-11-30 21:56

    For me, I had two views in two separate nav controllers. I had to use a combination of the above.

    var vc = self.storyboard?.instantiateViewControllerWithIdentifier("WelcomeViewController") as! WelcomeViewController
        var navigationController = UINavigationController(rootViewController: vc)
        self.presentViewController(navigationController, animated: true, completion: nil)
    

    Swift 3.x

            let secondVC = self.storyboard?.instantiateViewController(withIdentifier: "VC-ID" as! yourViewController
            let navigationVC = UINavigationController(rootViewController: secondVC)
            self.present(navigationVC, animated: true, completion: nil)
    
    0 讨论(0)
提交回复
热议问题