본문 바로가기

iOS

UIKit 화면 상태

728x90
반응형
SMALL
  • sceneDidDisconnect: Scene이 연결이 끊어진 후 호출되는 메서드입니다. Scene이 종료되거나 중단된 경우에 호출됩니다.
  • sceneWillResignActive: Scene이 비활성화될 예정인 시점에 호출되는 메서드입니다. 사용자의 상호작용을 받지 않게 되는 경우에 호출됩니다.
    ->SwiftUI 의 inactive랑 비슷합니다. status bar 를 내렸을 때, 홈 인디케이터로 화면을 줄였을 때 이벤트가 발생합니다.
  • sceneDidBecomeActive: Scene이 활성화된 후 호출되는 메서드입니다. 사용자가 Scene을 활성화하거나 다시 포그라운드로 가져오면 호출됩니다.
    ->SwiftUI 의 ative상태랑 비슷합니다. 앱이 화면에서 제일 위에서 실행 중일 때 이벤트가 발생합니다.
  • sceneWillEnterForeground: Scene이 포그라운드로 이동하기 전에 호출되는 메서드입니다. Scene이 백그라운드에서 포그라운드로 전환될 때 호출됩니다.
    ->화면이 꺼졌을 때, 바탕화면에서 앱으로 돌아올 때 가장 먼저 실행됩니다. 
  • sceneDidEnterBackground: Scene 백그라운드로 이동한 호출되는 메서드입니다. Scene 포그라운드에서 백그라운드로 전환될 호출됩니다.
    -> SwiftUI의 background랑 비슷합니다. 화면이 바탕으로 빠져 나가면 sceneWillResignActive을 거쳐 background 상태가 됩니다.  
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let _ = (scene as? UIWindowScene) else { return }
    }

    func sceneDidDisconnect(_ scene: UIScene) {
        print("didDisconnet")
        // Called as the scene is being released by the system.
        // This occurs shortly after the scene enters the background, or when its session is discarded.
        // Release any resources associated with this scene that can be re-created the next time the scene connects.
        // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
    }

    func sceneDidBecomeActive(_ scene: UIScene) {
        print("active")
        // Called when the scene has moved from an inactive state to an active state.
        // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
    }

    func sceneWillResignActive(_ scene: UIScene) {
        print("willResignActive")
        // Called when the scene will move from an active state to an inactive state.
        // This may occur due to temporary interruptions (ex. an incoming phone call).
    }

    func sceneWillEnterForeground(_ scene: UIScene) {
        print("enterforground")
        // Called as the scene transitions from the background to the foreground.
        // Use this method to undo the changes made on entering the background.
    }

    func sceneDidEnterBackground(_ scene: UIScene) {
        print("background")
        // Called as the scene transitions from the foreground to the background.
        // Use this method to save data, release shared resources, and store enough scene-specific state information
        // to restore the scene back to its current state.
    }

 

 

728x90
반응형
LIST

'iOS' 카테고리의 다른 글

ViewBuilder  (0) 2023.06.01
Global DispatchQueue, QoS  (0) 2023.05.30
SwiftUI active, inavtive, background 상태  (0) 2023.05.18
SwiftUI 이미지 캐시처리  (0) 2023.05.11
UIKit 화면 전환 방법과 예제  (0) 2023.05.09