xcode UIWindow 和 UIView 的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8233976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The difference between a UIWindow and a UIView
提问by Stanley
After creating a blank xib file, it seems that we can either drag a UIWindow or UIView to cover the entire screen. My question is what are the practical differences between the two and in what circumstances that we should use one over the other?
创建一个空白的xib文件后,好像我们可以拖动一个UIWindow或者UIView来覆盖整个屏幕。我的问题是两者之间的实际区别是什么,在什么情况下我们应该使用一个而不是另一个?
回答by beryllium
Windows do not have any visible content themselves but provide a basic container for your application's views. Views define a portion of a window that you want to fill with some content. Typically, there is only one window in an iOS application.
Windows 本身没有任何可见的内容,但为应用程序的视图提供了一个基本容器。视图定义了要填充某些内容的窗口部分。通常,iOS 应用程序中只有一个窗口。
回答by benzado
It's not an either/or kind of thing. Your app must have a UIWindow instance that is the container for the UIView instances you present.
这不是一种非此即彼的事情。您的应用程序必须有一个 UIWindow 实例,它是您呈现的 UIView 实例的容器。
An app can either load the UIWindow instance from a nib file, or it can create it programmatically. Look at some sample code to see how it is done.
应用程序可以从 nib 文件加载 UIWindow 实例,也可以以编程方式创建它。查看一些示例代码以了解它是如何完成的。