ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Preparing Your UI to Run in the Background - Scenes - UIKit
    iOS/🍎 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 을 λ³΄λƒ…λ‹ˆλ‹€:

     

    μš°λ¦¬λŠ” 두 가지 νƒ€μž…μ˜ 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:

    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.

    •  

    λŒ“κΈ€

μ–΄μ œλ³΄λ‹€ λ°œμ „ν•œ λ‚˜