SceneDelegate.swift 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // SceneDelegate.swift
  3. //
  4. import UIKit
  5. class SceneDelegate: UIResponder, UIWindowSceneDelegate {
  6. var window: UIWindow?
  7. func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
  8. // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
  9. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
  10. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
  11. guard let _ = (scene as? UIWindowScene) else { return }
  12. guard let windowScene = (scene as? UIWindowScene) else { return }
  13. window = UIWindow(frame: windowScene.coordinateSpace.bounds)
  14. window?.windowScene = windowScene
  15. window?.rootViewController = UINavigationController(rootViewController: GifListViewController())
  16. window?.makeKeyAndVisible()
  17. }
  18. func sceneDidDisconnect(_ scene: UIScene) {
  19. // Called as the scene is being released by the system.
  20. // This occurs shortly after the scene enters the background, or when its session is discarded.
  21. // Release any resources associated with this scene that can be re-created the next time the scene connects.
  22. // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
  23. }
  24. func sceneDidBecomeActive(_ scene: UIScene) {
  25. // Called when the scene has moved from an inactive state to an active state.
  26. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
  27. }
  28. func sceneWillResignActive(_ scene: UIScene) {
  29. // Called when the scene will move from an active state to an inactive state.
  30. // This may occur due to temporary interruptions (ex. an incoming phone call).
  31. }
  32. func sceneWillEnterForeground(_ scene: UIScene) {
  33. // Called as the scene transitions from the background to the foreground.
  34. // Use this method to undo the changes made on entering the background.
  35. }
  36. func sceneDidEnterBackground(_ scene: UIScene) {
  37. // Called as the scene transitions from the foreground to the background.
  38. // Use this method to save data, release shared resources, and store enough scene-specific state information
  39. // to restore the scene back to its current state.
  40. }
  41. }