rootViewController 需要澄清
公平地说,定义为 MainWindow.xib 一部分的 Controller 是应用程序的根控制器吗?
此外,是否真的假设 RootController 始终负责向用户显示哪个视图?
Is it fair to say that Controller defined as part of MainWindow.xib is application's root controller?
Additionally, is true to assume that RootController is always the one responsible for what view is being shown to the user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
某些基于标准 IB 窗口的项目恰好就是这种情况,但最终您需要一个窗口和一个视图来向用户显示某些内容。
只是观点:
考虑一下这一点。我创建了一个空项目,添加一个视图(只是 MyView.xib),向该项目和此代码添加一个按钮。没有根控制器 - 只有窗口和视图。
对于典型的基于窗口:
-info.plist 指向 MainWindow.xib(主 nib 文件基本名称),文件所有者指向应用程序委托,应用程序委托的 viewController 指向 UIViewController。然后,通常将窗口 rootviewController 设置为上面设置的 viewController。
但是,如果您查看这个基于导航的应用程序(MasterDetail 项目),就会发现没有 MainWindow.xib。
main.m 指向appDelegate。
应用程序委托在 navigationController 中创建主控制器,并且以编程方式创建的 navigationController 成为 rootViewContoller
最后,在这个编程示例中,甚至没有设置 Windows rootViewController。
导航控制器的视图直接添加到窗口中。一天结束时,窗户只是欣赏风景。您可以设置它或者根控制器可以控制它。
That happens to be the case with some standard IB window based projects but, ultimately you need a window and a view to show something to the user.
Just the view:
Consider this. I created an empty project, add a view (just MyView.xib), add a button to that and this code. No root controllers - just the window and the view.
For a typical window based:
The -info.plist points to MainWindow.xib (Main nib file base name), the File Owner points to the app delegate, the app delegate's viewController points to a UIViewController. Then, typically, window rootviewController is set to the viewController set above.
But, if you look at this navigation based app (MasterDetail project), there is no MainWindow.xib.
main.m points to the appDelegate.
the app delegate create the master controller in a navigationController and the navigationController that was create programmatically becomes the rootViewContoller
And finally, in this programmatic example the windows rootViewController is not even set.
The view of the navigation controller is added directly to the window. At the end of the day, the window is just hosting a view. You can set it or the root controller can control it.