Swift presentViewController

后端 未结 13 2056
悲&欢浪女
悲&欢浪女 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:54

    You can use code:

    if let vc = self.storyboard?.instantiateViewController(withIdentifier: "secondViewController") as? secondViewController {
       let appDelegate = UIApplication.shared.delegate as! AppDelegate
       appDelegate.window?.rootViewController = vc
    }
    

提交回复
热议问题