将 Storyboard 中的 UINavigationController 链接到 AppDelegate [英] Linking UINavigationController in Storyboard to AppDelegate

查看:18
本文介绍了将 Storyboard 中的 UINavigationController 链接到 AppDelegate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用单视图模板启动了一个 iOS 应用程序.然后我通过将它拖到故事板中来添加一个导航控制器.我如何从我的应用程序委托中引用它?我尝试按住 ctrl 将它拖动到我的 AppDelegate 插座样式中,但这显然不起作用.我该怎么办?实例化一个,然后将其指定为 rootview 控制器?

So I started an iOS app with the single view template. I then added a navigation controller by dragging it into the storyboard. How do I references this from my app delegate? I tried ctrl-dragging it into my AppDelegate outlet-style but that obviously doesn't work. What do I do? Instantiate one and then assign it as rootview controller?

最后,我想使用 AppDelegate 将视图设置为导航控制器的顶部.谢谢!

By the end of this I'd like to use the AppDelegate to set the view to the top of the navigation controller. Thanks!

推荐答案

在 IB 中,您应该选择导航控制器,然后单击检查器中的是初始视图控制器"复选框——这会自动使该控制器成为根视图窗口的控制器.在您的应用委托中,您可以使用 self.window.rootViewController 获取对导航控制器的引用,并根据需要将其分配给一个属性.

In IB you should select the navigation controller and then click the "Is Initial View Controller" check box in the inspector -- this automatically makes that controller the root view controller of the window. In your app delegate, you can get a reference to the navigation controller with self.window.rootViewController and assign it to a property if you want.

这篇关于将 Storyboard 中的 UINavigationController 链接到 AppDelegate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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