设置UIWindow的rootViewController有什么作用?
将视图控制器分配给此属性(以编程方式 或使用 Interface Builder)将视图控制器的视图安装为 窗口的内容视图。
上面的引用来自 UIWindow 的参考。我的问题是关于特定阶段的:
“将视图控制器的视图安装为 窗口的内容视图”
内容视图究竟指什么?
Assigning a view controller to this property (either programmatically
or using Interface Builder) installs the view controller’s view as the
content view of the window.
The above quote is from the UIWindow's reference. My question is about the particular phase :
"installs the view controller’s view as the
content view of the window"
What does exactly content view refer to ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 rootViewController 属性出现之前,大多数应用程序在应用程序委托中都有这样的代码:
此代码将视图控制器的视图设置为主视图,但 UIWindow 实例没有引用拥有该视图的控制器。
当您使用 rootViewController 属性时,您不再需要将视图控制器的视图添加到 UIWindow 实例中,这是自动完成的。因此代码行数保持不变,但现在您的 UIWindow 具有对视图控制器的引用。
因此,在较新的应用程序中,我们现在的代码如下所示:
Before the
rootViewController
property came along, most apps had code like this in the application delegate:This code set the view controller's view as the main view, but the UIWindow instance had no reference to the controller owning that view.
When you use the
rootViewController
property, you don't need to add the view controller's view to the UIWindow instance anymore, this is done automatically. So the number of lines of code stays the same, but now your UIWindow has a reference to the view controller.So, in newer applications, we now have code that looks like this: