// 从storyboard创建MainViewController
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@“Main” bundle:[NSBundle mainBundle]];
YLSMainViewController mainViewController = (YLSMainViewController)[storyboard instantiateViewControllerWithIdentifier:@“mainViewController”];
[self presentViewController:mainViewController animated:YES completion:nil];

在调用之前,需要在storyboard里,给目标ViewController设置identifier

用代码创建并实例化在storyboard中声明的ViewController
这样就可以通过编码方式,创建storyboard中的ViewController了

相关文章: