UIScreen, UIScene, UIWindow 개념 정리!

UIScreen
UIScreen은 iOS, iPadOS, tvOS에 attach된 하드웨어 스크린에 대한 정보를 나타내는 객체이다. 내장된 디스플레이(예, iOS라면 핸드폰 스크린)나 연결된 외부 display(예, tvOS에서 연결된 tv)에 대한 정보를 가지고 있다.
이 객체를 직접적으로 만들어서 사용할 일은 없고, UIWindow 객체를 통해 얻어서 사용하면 된다.
UIScene
앱의 UI를 나타내는 하나의 객체(즉, app instance)로, 한개 이상 만들 수 있다. (iOS13 이상)
-> 프로그래밍 할 때 객체라는 개념을 많이 사용하죠? 앱 자체의 객체를 UIScene이라고 하고, 이 객체를 여러개 생성해서 사용할 수 있습니다. 한 앱의 UIScene이 여러개 만들어졌을 때, 각각의 객체들은 메모리를 공유합니다.
UIWindowScene
UIScene을 상속하는 객체이고, UIKit에서는 UIWindowScene을 이용해서 앱의 객체를 관리한다. 이 객체는 window들과 view controller들을 포함하고 관리하는 역할을 한다. 각각의 scene은 상응하는 UIWindowSceneDelegate이 있어서, 이를 이용해 UIKit과 app 간의 의사 소통을 조율하게 된다. Scene들은 동일한 메모리와 프로세스 공간을 공유하며 동시에 동작한다. 그렇기 때문에 하나의 앱은 여러개의 scene과 scene delegate 객체들을 동시에 가질 수 있다.
iPad앱 중에는, Notes 앱처럼 동일한 앱을 두개 열어서 창을 띄워 놓을 수가 있는 기능을 제공하는 앱들이 있다. 이런 방식이 바로 여러개의 UIScene을 사용하는 방식이다. (마치 컴퓨터에서 Chrome 윈도우를 여러개 띄워놓고 사용하는 것과 유사한 형식이나, UIWindow가 아니라 UIScene이 그 역할을 해준다.)

UIWindow
앱의 UI 요소들을 보여주는 역할과 View들에게 이벤트를 전달하는 역할을 수행한다. 자체적으로는 시각적인 화면을 가지고 있지 않다.
주요한 역할은 크게 세 가지로 정리할 수 있다.
1. 앱의 UI들을 가지고 있는다.
2. 터치 이벤트를 view나 다른 앱 객체들에게 전달해준다.
3. View controller와 함께 기기의 방향 전환(가로, 세로)에 대응한다.
main window도 있고 부수적인 window들도 있다. main window는 사용자가 일반적으로 보는 앱의 화면이라고 보면 되고, 부수적인 window로는 텍스트 입력할 때 하단에서 올라오는 system keyboard와 같은 것이 있다.
+추가적으로, 하나의 UIWindow는 하나의 device display와 연결되어 있다.
참고자료
Understanding Windows and Screens
Understanding Windows and Screens A window handles the overall presentation of your app’s user interface. Windows work with views (and their owning view controllers) to manage interactions with—and changes to—the visible view hierarchy. Every app has
developer.apple.com
https://developer.apple.com/documentation/uikit/scenes
Scenes | Apple Developer Documentation
Manage multiple instances of your app’s UI simultaneously, and direct resources to the appropriate instance of your UI.
developer.apple.com
https://developer.apple.com/documentation/uikit/uiwindow#Understand-keyboard-interactions
UIWindow | Apple Developer Documentation
The backdrop for your app’s user interface and the object that dispatches events to your views.
developer.apple.com
https://ios-development.tistory.com/1011
[iOS - swift] UIWindow, keyWindow, UITextEffectsWindow, UIKeyboardWindowScene, UIRemoteKeyboardWindow 개념
UIWindow 개념 UIView의 서브클래싱이고, 앱의 뷰들을 표출할 컨테이너 역할과 이벤트를 수신하는 역할을 담당 키보드 이벤트의 대상으로 지정하는데 UIWindow를 통해 이벤트를 받고 처리 UIWindow 하위
ios-development.tistory.com