ios 手写代码的controller与storyboard里的controller跳转

来源:互联网 发布:云梯软件官网 编辑:程序博客网 时间:2024/05/19 03:29

最近写了一个应用是用storyboard搭建的,想添加一些功能,这个功能是用纯代码写的,想实现代码创建的controller使用完后调用storyboard中的controller,发现并不难实现



首先,在storyboard中找到要跳转的viewController,然后在身份检查器中修改其中的storyboard id。

然后在delegate类中写入一下代码:


UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];        UITabBarController *MianController = (UITabBarController*) [storyboard instantiateViewControllerWithIdentifier:@"MainController"];            self.window.rootViewController = MianController;

然后就完事了,这里跳转到的是storyboard中标识符为MainController的UITabBarController。
0 0
原创粉丝点击