通过替换 windows 根控制器在多个故事板之间移动 [英] Move between multiple storyboards by replacing the windows root controller

查看:25
本文介绍了通过替换 windows 根控制器在多个故事板之间移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在单个故事板上的 VC 之间移动,我使用了帖子中的第一个自定义转场:无堆叠的双向故事板旅行 这将窗口的根视图控制器替换为目标视图控制器,因此 VC 不会堆叠并导致内存分配问题.

To move between VCs on a single storyboard, I use the first custom segue from the post : bidirectional storyboard travel without stacking This replaces the window's root view controller with the destination view controller, so the VCs do not stack and cause memory allocation issues.

我需要使用多个故事板,因此我采用了一种移动到第二个故事板的方法,该方法将 Windows 根控制器替换为新故事板的初始 VC(即与我在整个过程中使用的自定义转场类似的方式)项目的其余部分.)

I need to use multiple storyboards and so I am after a method of moving to a second storyboard that replaces the windows root controller with the initial VC of the new storyboard (I.e in a similar way to the custom segue I have used throughout the rest of the project.)

理想情况下,该解决方案应该适用于 IOS6 &IOS7(pseudo-segue方法已经更新到IOS7而已)

The solution should ideally work for IOS6 & IOS7 (the pseudo-segue method has been updated to IOS7 only)

有什么想法吗?

推荐答案

你不能用 segue 做到这一点.Segues 只能在同一个故事板中的控制器之间进行.唯一的方法是在代码中实例化第一个控制器,并将其设置为窗口的根视图控制器.

You can't do this with a segue. Segues can only be made between controllers in the same storyboard. The only way to do this, is in code by instantiating that first controller, and setting it as the window's root view controller.

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"SomeOtherStoryboard" bundle:nil];
NewController *new = [sb instantiateInitialViewController];
self.view.window.rootViewController = new;

这篇关于通过替换 windows 根控制器在多个故事板之间移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆