简体   繁体   English

如何将导航控制器添加到父视图的子视图

[英]How to add a navigation controller to a subview of a parent view

I have a design where I have a main view controller, with three subviews contained within. 我的设计中有一个主视图控制器,其中包含三个子视图。 How can I add a UINavigationController to one of the subviews to manage the view stack for that subview only? 如何将UINavigationController添加到子视图之一以仅管理该子视图的视图堆栈?

Since iOS 5 you can create custom container view controllers. 从iOS 5开始,您可以创建自定义容器视图控制器。 I recommend creating a container that holds your 3 views (each of them being view controller objects). 我建议创建一个容纳3个视图的容器(每个视图都是视图控制器对象)。 And since UINavigationController is a UIViewController subclass, you should be able to add it to your container. 由于UINavigationControllerUIViewController子类,因此您应该可以将其添加到容器中。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM