简体   繁体   English

UINavigationController和IBOutlet

[英]UINavigationController and IBOutlet

I created a UInavigation controller in my xib file. 我在xib文件中创建了一个UInavigation控制器。 The UINavigation controller is the top level control. UINavigation控制器是顶级控件。 I don't need a parent view. 我不需要父视图。 Later on I will manually add the UINavigation controller to the window. 稍后,我将手动将UINavigation控制器添加到窗口中。

What is the best way to instantiate the UINavigationController? 实例化UINavigationController的最佳方法是什么? I can't seem to figure out how to do this. 我似乎不知道该怎么做。

If you do not need to do anything special in the .xib file it is way easier to do this programmatically by adding the following code to your app delegate: 如果您不需要在.xib文件中执行任何特殊操作,则可以通过将以下代码添加到您的应用程序委托中来以编程方式更轻松地执行此操作:

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:myView]; //myView is a view you previously created
[self.window addSubview:nav.view];

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

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