swift presentViewController programmatically finds nil in destinationVC VDL

有些话、适合烂在心里 提交于 2019-12-01 14:38:09

So when instantiating a VC (storyboard-created), first we need to route our call through the UIStoryboard by name

let storyboard = UIStoryboard(name: "Main", bundle: nil)  

then instantiate a VC using the Storyboard ID of our storyboard setup VC

let vc = storyboard.instantiateViewControllerWithIdentifier("VC1") as VC1    //VC1 refers to destinationVC source file and "VC1" refers to destinationVC Storyboard ID

Then we can present VC using

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

This will import all of destinationVC's objects with their IBOutlet references.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!