iOS中场景和视图之间的区别 [英] Difference between a Scene and a View in iOS
问题描述
我是iOS新手我无法理解场景和视图之间的区别。不幸的是Apple的文档没有帮助我。我看到一个场景就是你在屏幕上看到的。但这不是一个观点吗?这两个可互换的术语是?如果没有,那么功能和最佳实践有何区别? ViewController如何发挥作用?
I'm new to iOS I'm having trouble understanding the difference between scene and a view. Unfortunately Apple's documentation isn't helping me. I read that a scene is what you see on the screen. But isn't that what a view is? Are these two interchangeable terms? If not what are the differences, both functionality and best practice? How does a ViewController come into play for both of these?
非常感谢任何解释或链接。
Any explanations or links are much appreciated.
推荐答案
简单来说:
A UIView
是一个显示在屏幕上的矩形区域。
A UIView
is a rectangular area that is displayed on the screen.
此时屏幕上显示的一组视图。
A collection of Views displayed on the screen at the moment.
在下图中,蓝色区域和黄色区域是视图,而整个屏幕是ViewController。
In the following image, blue area and yellow area are Views, whereas the entire screen is a ViewController.
ViewController是特定的一部分序列。
A ViewController which is a part of a specific sequence.
但是,技术定义略有不同:
However, the technical definitions are a little different:
UIIView是CALayer的包装器。它包含一系列子视图,这意味着它本身就是一组视图。您可以将其想象为树结构。
A UIIView is a wrapper to CALayer. It holds an array of subviews which implies that it's a collection of views by itself. You can imagine this as a tree structure.
ViewController是一个控制器,它包含对根视图。
这样,您可以遍历控制器中的叶节点或任何子视图。
A ViewController is a controller which holds a reference to the root view. This way, you can traverse the leaf node or any subview from the controller.
场景是故事板的一个上下文中ViewController的另一个术语。
"Scene" is another term for a ViewController in one context of storyboard.
这篇关于iOS中场景和视图之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!