Last active
July 28, 2024 10:11
-
-
Save eldaroid/14f440081695cc47a64b65aafaea3781 to your computer and use it in GitHub Desktop.
Исследуем жизненный цикл iOS Scene (методы SceneDelegate)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
var window: UIWindow? | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
guard let windowScene = (scene as? UIWindowScene) else { return } | |
// Настройка окна приложения | |
window = UIWindow(windowScene: windowScene) | |
let initialViewController = ViewController() | |
window?.rootViewController = initialViewController | |
window?.makeKeyAndVisible() | |
} | |
// MARK: - SceneDelegate Lifecycle | |
func sceneDidDisconnect(_ scene: UIScene) { | |
Logger.shared.log("😍 - 0) sceneDidDisconnect") | |
} | |
func sceneDidBecomeActive(_ scene: UIScene) { | |
Logger.shared.log("😍 - 3) applicationDidBecomeActive") | |
} | |
func sceneWillResignActive(_ scene: UIScene) { | |
Logger.shared.log("😍 - 4) applicationWillResignActive") | |
} | |
func sceneDidEnterBackground(_ scene: UIScene) { | |
Logger.shared.log("😍 - 5) applicationDidEnterBackground") | |
} | |
func sceneWillEnterForeground(_ scene: UIScene) { | |
Logger.shared.log("😍 - 6) applicationWillEnterForeground") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Наглядная визуализация методов жизненного цикла SceneDelegate:
Сценарии вызовов каждого метода: