Difference between a Scene and a View in iOS

前端 未结 1 511
孤街浪徒
孤街浪徒 2021-02-05 07:55

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 yo

1条回答
  •  余生分开走
    2021-02-05 08:24

    In simple terms:

    View

    A UIView is a rectangular area that is displayed on the screen.

    ViewController

    A collection of Views displayed on the screen at the moment.

    In the following image, blue area and yellow area are Views, whereas the entire screen is a ViewController.

    Anatomy of a UIView

    Scene

    A ViewController which is a part of a specific sequence.

    enter image description here

    However, the technical definitions are a little different:

    UIView

    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.

    Scene

    "Scene" is another term for a ViewController in one context of storyboard.

    0 讨论(0)
提交回复
热议问题