代码获取storyboard中定义的UIViewController

来源:互联网 发布:凶宅美人头 知乎 编辑:程序博客网 时间:2024/06/06 15:48

storyboard 创建了多个UIViewController,但由于项目原因,不能使用segue,所以需要在button的单击事件中,调用另一个UIViewController,并显示出来,代码如下:


UIStoryboard *storyboard = [UIStoryboardstoryboardWithName:@"Main"bundle:[NSBundlemainBundle]];

GameViewController *gvc = (GameViewController*)[storyboard instantiateViewControllerWithIdentifier:@"id_my_view_controller"];

[self presentViewController:gvc animated:TRUE completion:nil];


// Main 为storyboard 的名字;id_my_view_controller 为该UIViewController 在storyboard 里设置的 id。

1 0
原创粉丝点击