将现有的UINavigationController嵌入到新的视图控制器中 [英] Embedding an existing UINavigationController to new view controllers

查看:56
本文介绍了将现有的UINavigationController嵌入到新的视图控制器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个带有导航控制器和几个视图控制器的情节提要.

Suppose I have a storyboard with a navigation controller and several view controllers.

在我尝试添加新的视图控制器并将其与现有的UINavigationController关联之前,一切都很好.当我进入Editor> Embed> Navigation Controller时,Xcode会帮助创建一个新的控制器,这正是我所不想要的.当我尝试拖动以创建线框时,我创建了segue关系,这也是我不想要的.

All is well until I try to add a new view controller and would like to associate it with the existing UINavigationController. When I go to Editor>Embed>Navigation Controller, Xcode helpfully creates a new controller, which is precisely what I don't want. When I attempt to drag to create a wireframe, I create a segue relationship, which again is what I don't want.

有没有一种方法可以使新的视图控制器与现有的导航控制器完美配合?

Is there a way to make new view controllers play nice with an existing nav controller?

推荐答案

我认为您正在错误地考虑UINavigationController. UINavigationController只是一个容器视图控制器,它管理视图控制器的层次结构.您从一个UINavigationController开始,该UINavigationController恰好具有一个根视图控制器(听起来您想要多个,这不会发生).当您推送一个新的视图控制器时,它将被推送到相同的UINavigationController上.因此,如果要与单个UINavigationController关联的多个视图控制器,则它们必须分层堆叠到根视图控制器上.

I think you are thinking of the UINavigationController incorrectly. UINavigationController is just a container view controller that manages a hierarchy of view controllers. You start with one UINavigationController, which has exactly one root view controller (it sounds like you want more than one, which isn't going to happen). When you push a new view controller, it is pushed onto the same UINavigationController. So if you want multiple view controllers associated with a single UINavigationController, they have to hierarchically stack onto the root view controller.

这篇关于将现有的UINavigationController嵌入到新的视图控制器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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