Difference between a Scene and a View in iOS
Asked Answered
M

1

28

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.

Maldonado answered 4/9, 2014 at 17:52 Comment(2)
Google: iOS scene vs view - hubpages.com/hub/… or https://mcmap.net/q/504612/-cocoa-scene-vs-viewBowen
That was really helpful to explain what a Scene is but I'm still a little shaky on what a View is. Is it simply what a ViewController controls (sounds intuitive)? And if so how is that different from a Scene? Is it that a Scene is something that the Storyboard handles and a View is something handled by XIB files?Maldonado
F
25

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.

Frequently answered 4/9, 2014 at 18:6 Comment(5)
Could you explain a little more on how one would interact with the a View and a Scene? And best practices for both?Maldonado
The explanation on the bottom was most helpful.Maldonado
@KunalBalani Do you have sources for the technical definitions you have given at the end of your answer?Corncob
That definition of "Scene" is basically useless without context. @Bowen 's comment on the question is more useful.Weatherwise
Is this used for macOS or is it (mostly) for IOS?Inspissate

© 2022 - 2024 — McMap. All rights reserved.