简体   繁体   English

使用Storyboard将UITabViewController放在UINavigationViewController内

[英]Putting a UITabViewController inside UINavigationViewController with storyboard

I'm using a storyboard to to lay out my app, and I would like to put a UINavigationController as my root and then UITabViewController as the root of that. 我正在使用情节提要来布置我的应用程序,我想将UINavigationController作为我的根,然后将UITabViewController作为它的根。 The main reasons I'm doing this are to save memory and to reduce the complexity of the controller tree. 我这样做的主要原因是为了节省内存并降低控制器树的复杂性。

So, is this an ok practice, and will this result in a more memory-efficient app than putting a separate nav controller in each tab? 因此,这是一种好的做法,并且与在每个选项卡中放置单独的导航控制器相比,这是否会导致应用程序的内存使用效率更高?

According to apple documentation. 根据苹果的文件。 The tab bar controller should always be your root controller in this case. 在这种情况下,选项卡栏控制器应始终是您的根控制器。 Here is a tutorial on how to put a navigation controller inside of a tab bar controller. 这是有关如何将导航控制器放在标签栏控制器内部的教程

Your UITabBarController should come first in the hierarchy, followed by your UINavigationController, and then your views. 您的UITabBarController应该首先在层次结构中,然后是UINavigationController,然后是您的视图。 I would not worry terribly much about memory here: your app should already do the right things when iOS is low on memory (release what you can; rebuild it when requested by the user). 我在这里不必担心太多内存:当iOS内存不足时,您的应用程序应该已经做了正确的事情(释放您所能的;在用户请求时重建它)。

Ok, I found the answer. 好的,我找到了答案。

This question is regarding combining tab and navigation controllers while using a storyboard . 这个问题是关于在使用情节提要时组合选项卡和导航控制器。 Here's a tutorial that that addresses this situation. 这是解决这种情况的教程。

http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1 http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

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

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