Swift presentViewController

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

    For those getting blank/black screens this code worked for me.

        let vc = self.storyboard?.instantiateViewController(withIdentifier: myVCID) as! myVCName
        self.present(vc, animated: true, completion: nil)
    

    To set the "Identifier" to your VC just go to identity inspector for the VC in the storyboard. Set the 'Storyboard ID' to what ever you want to identifier to be. Look at the image below for reference.

提交回复
热议问题