Swift presentViewController

后端 未结 13 2105
悲&欢浪女
悲&欢浪女 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条回答
  •  旧时难觅i
    2020-11-30 21:53

    Just use this : Make sure using nibName otherwise preloaded views of xib will not show :

    var vc : ViewController = ViewController(nibName: "ViewController", bundle: nil) //change this to your class name

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

提交回复
热议问题