App State
App의 State에는 크게 두 가지가 있다.
- Foreground State
App은 사용자의 주목을 받으며 많은 시스템 리소스를 차지한다. - Background State
App은 화면에 나타나지 않으며 최소한의 일을 한다.
App은 State가 변화함에 따라 그에 맞는 동작을 해야 한다.
UIKit은 App의 State가 변화할 때 Delegate 객체의 함수를 호출하여 State의 변화를 알린다.
Scene-Based App
Scene-Based의 App은 IOS 13 이후에서 지원된다.
App에서 Scene Support를 Enable 할 경우 App은 Life Cycle Event에 반응하기 위해 UISceneDelegate 객체를 사용한다.
Scene은 Device에서 동작하는 App의 하나의 UI 객체를 나타낸다.
사용자는 각 App에 여러개의 Scene을 생성할 수 있으며 각 Scene은 고유의 Life Cycle을 가진다.
# 참고 #
Scene은 옵트인(Opt-In) 기능이기 때문에 사용하기 위해서는 사용자의 동의를 얻어야 한다.
이를 위해 UIApplication SceneManifest Key를 App의 Info.plist 파일에 추가해야 한다.
Life Cycle

User나 System이 Scene을 요구하면 UIKit은 Scene을 Unattached State로 생성한다.
일반적으로,
- User가 요구한 Scene은 Foreground로 변화한다.
- System이 요구한 Scene은 Background로 변화한다.
UIKit은 언제든지 Background, Suspended State의 Scene을 Unattached State로 만들 수 있다.
App-Based App
IOS 12 이하의 UIKit 은 UIApplicationDelegate 객체로 모든 Life Cycle Event를 전달한다.
UIApplicationDelegate는 화면에 표시되는 Window를 포함하여 모든 Window를 관리한다.
즉, App State의 변화는 App 전체 UI에 영향을 끼친다.
Life Cycle

App이 실행되면 UI 화면 출력 여부에 따라 App을 Foreground 혹은 Background 상태로 전환한다.
Foreground로 시작할 때 System은 Inactive에서 Active로 자동으로 전환된다.
이후, App이 종료될 때까지 Active와 Background사이에서 상태변화를 지속한다.
Reference
https://developer.apple.com/documentation/uikit/uiscene
Apple Developer Documentation
developer.apple.com
https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle
Apple Developer Documentation
developer.apple.com
'IOS > UIKit' 카테고리의 다른 글
[UIKit] UINavigationBar (0) | 2021.10.24 |
---|---|
[UIKit] UINavigation Controller (0) | 2021.10.23 |
[UIKit] UIApplication (0) | 2021.10.08 |