简体   繁体   English

如何在情节提要中连接下一个后推动viewController

[英]How to push the viewController after the next one connected in the storyboard

What is the strategy & API we can use to push to a viewController after the next one while retaining the view hierarchy? 在保留视图层次结构的同时,可用于下一个视图控制器的策略和API是什么?

So for example when the state of the rootViewController is one way i want to show a list of collections. 因此,例如,当rootViewController的状态是一种方式时,我想显示集合列表。 When the state of the rootViewController is another way i want to show the details of one of those collections AND preserve the navigation hierarchy so that we can pop one level back to the collection and pop a second time to the rootViewController. 当rootViewController的状态是另一种方式时,我想显示其中一个集合的详细信息并保留导航层次结构,以便我们可以将一级弹出回到集合,然后第二次弹出到rootViewController。

A possible solution would be to check the state of the rootViewController in the middleVC and have the middleViewController decided whether or not to push the 3rd ViewController. 一个可能的解决方案是检查middleVC中rootViewController的状态,并让MiddleViewController决定是否推送第3个ViewController。 I'm not a fan of that idea because logic that belongs in the rootViewController is now in the middleVC and that seems like breaking encapsulation. 我不赞成这种想法,因为属于rootViewController的逻辑现在位于MiddleVC中,这似乎破坏了封装。 Is it? 是吗?

Thanks for the advice. 谢谢你的建议。

As I can suggest you is to push your third view controller as usual, the put you [navigationController viewControllers] in NSArray then insert your second viewController at index 1 我可以建议您像往常一样推动第三个视图控制器,将[navigationController viewControllers]放入NSArray,然后在索引1处插入第二个viewController。

So you are at the rootViewController Controller1 index 0 因此,您位于rootViewController Controller1索引0

you push your desired viewController Controller3 index 1 你推你想要的viewController Controller3索引1

then you insert Controller2 at index 1 so your Controller3 become index 2. 然后在索引1处插入Controller2 ,以便Controller3成为索引2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从故事板中的appdelegate推送viewcontroller - How to push viewcontroller from appdelegate in storyboard 如何将一个Storyboard的ContainerView链接到另一个Storyboard中的ViewController? - How to link ContainerView of one Storyboard to ViewController in another Storyboard? 使用Storyboard时不通过Storyboard推送ViewController - Push a ViewController not through Storyboard while working with Storyboard 如何在导航控制器内的storyboard中从appdelegate推送viewcontroller - How to push viewcontroller from appdelegate in storyboard inside navigation controller 如何通过故事板将推送通知中的数据传递给ViewController? - How to pass data to a ViewController from push notification through the storyboard? 每次重新启动 Xcode 8 后,情节提要中都会重复警告仅针对一个 ViewController - Warnings repeated in storyboard after every restart of Xcode 8 for only one ViewController 在 Storyboard 中隐藏一个 ViewController 的 NavigationBar - Hide NavigationBar for one ViewController in Storyboard 如何使用故事板为一个viewController添加和编辑功能 - how to give one viewController add and edit functionality using storyboard 使用storyboard时如何在其viewController中获取tabBarController? - How to get tabBarController in one of its viewController when using storyboard? iOS - 从代码和故事板推送viewController - iOS - Push viewController from code and storyboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM