-
Preparing Your UI to Run in the Background - Scenes - UIKitiOS/π Documentation 2021. 1. 29. 18:28
κ΄λ ¨ λ¬Έμ: developer.apple.com/documentation/uikit/app_and_environment/scenes
" μ±μ΄ `suspended`μνλ‘ λμ ν λλ₯Ό λλΉνκΈ° "
Overview
μ±μ΄ `background` μνλ‘ μ νλλ λ°μλ μ¬λ¬ μ΄μ κ° μμ΅λλ€.
μ¬μ©μκ° `foreground` μνμΈ μ±μ μ’ λ£νλ©΄, μ±μ `background` μνλ‘ μ§μ νκ³ , 곧 UIKit μ΄ μ±μ `supsended`μνλ‘ λ°κΏλλ€.
μμ€ν μ μ±μ μ€ννμ¬ λ°λ‘ `background` μνλ‘ λ§λ€ κ±°λ, νΉμ `suspended` μνμ μ±μ `background` λ‘ μ ννμ¬ μ±μ΄ μ€μν μμ μ μννκ²λ μκ°μ μ€ μλ μμ΅λλ€.
μ±μ΄ `background` μνμ μλ€λ©΄, μ΅μνμΌλ‘ μμ ν΄μΌνλ©° μ¬μ€ μ무κ²λ νμ§ μλκ²μ μΆμ²ν©λλ€.
μ±μ΄ λ°©κΈ μ μ `foreground` μνμλ€λ©΄ `background transition`μ μ¬μ©νμ¬ μμ μ μ€μ§νκ³ κ³΅μ μμμ ν΄μ ν©λλ€.
λ§μ½ μ±μ΄ μ€μν μ΄λ²€νΈ μ²λ¦¬λ₯Ό μν΄ `background` μνλ‘ μ ν λμλ€λ©΄, κ·Έ μ΄λ²€νΈλ₯Ό μ μν μ²λ¦¬νκ³ μ΅λν 빨리 μ±μ μ’ λ£ν΄μΌ ν©λλ€.
λͺ¨λ κ²½μ°, μν μ νμ΄ λ°μνλ©΄ UIKit μ μ μ ν delegate μ€λΈμ νΈμ notification μ 보λ λλ€:
-
In iOS 13 and later—A UISceneDelegate object.
-
In iOS 12 and earlier—The UIApplicationDelegate object.
μ°λ¦¬λ λ κ°μ§ νμ μ delegate μ€λΈμ νΈ μ λΆλ₯Ό μ§μν μ μμ§λ§, UIKit μ κ°λ₯νλ€λ©΄ νμ scene delegate μ€λΈμ νΈλ₯Ό μ¬μ©ν©λλ€.
μ¦, UIKit λ transitoin κ³Ό κ΄λ ¨λμ΄μλ νΉμ μ¬μ μ°κ²°λμ΄μλ `scene delegate` μκ²λ§ `background`λ‘ μ§μ νλ€κ³ μλ €μ€λλ€.
#μμ±μ€
Quiet Your App upon Deactivation
The system deactivates apps for several reasons. When the user exits the foreground app, the system deactivates that app immediately before moving it to the background. The system also deactivates apps when it needs to interrupt them temporarily—for example, to display system alerts. In the case of a system panel, the system reactivates the app when the user dismisses the panel.
During deactivation, UIKit calls one of the following methods of your app:
-
For apps that support scenes—The sceneWillResignActive(_:) method of the appropriate scene delegate object.
-
For all other apps—The applicationWillResignActive(_:) method of the app delegate object.
Use deactivation to preserve the user’s data and put your app in a quiet state by pausing all major work; specifically:
-
Save user data to disk and close any open files.
-
Suspend dispatch and operation queues.
-
Don’t schedule any new tasks for execution.
-
Invalidate any active timers.
-
Pause gameplay automatically.
-
Don't commit any new Metal work to be processed.
'iOS > π Documentation' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[iOS] Object Graphs μ Archives, κ·Έλ¦¬κ³ Serialization (0) 2021.05.24 [iOS] NSCoding μ΄λ? (feat. μΈμ½λ©, λμ½λ©, μμΉ΄μ΄λΉ) (0) 2021.05.23 Preparing Your UI to Run in the Foreground - Scenes - UIKit (0) 2021.01.29 Scenes - UIKit (0) 2021.01.29 UIApplicationDelegate - UIKit (0) 2021.01.28 -