SceneDelegate.swift 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2019 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import UIKit
  15. class SceneDelegate: UIResponder, UIWindowSceneDelegate {
  16. var window: UIWindow?
  17. func scene(_ scene: UIScene,
  18. willConnectTo session: UISceneSession,
  19. options connectionOptions: UIScene.ConnectionOptions) {
  20. // Use this method to optionally configure and attach the UIWindow `window` to the provided
  21. // UIWindowScene `scene`. If using a storyboard, the `window` property will automatically
  22. // be initialized and attached to the scene. This delegate does not imply the connecting
  23. // scene or session are new (see `application:configurationForConnectingSceneSession`
  24. // instead).
  25. guard let _ = (scene as? UIWindowScene) else { return }
  26. }
  27. func sceneDidDisconnect(_ scene: UIScene) {
  28. // Called as the scene is being released by the system.
  29. // This occurs shortly after the scene enters the background, or when its session is discarded.
  30. // Release any resources associated with this scene that can be re-created the next time the
  31. // scene connects. The scene may re-connect later, as its session was not neccessarily
  32. // discarded (see `application:didDiscardSceneSessions` instead).
  33. }
  34. func sceneDidBecomeActive(_ scene: UIScene) {
  35. // Called when the scene has moved from an inactive state to an active state.
  36. // Use this method to restart any tasks that were paused (or not yet started) when the scene was
  37. // inactive.
  38. }
  39. func sceneWillResignActive(_ scene: UIScene) {
  40. // Called when the scene will move from an active state to an inactive state.
  41. // This may occur due to temporary interruptions (ex. an incoming phone call).
  42. }
  43. func sceneWillEnterForeground(_ scene: UIScene) {
  44. // Called as the scene transitions from the background to the foreground.
  45. // Use this method to undo the changes made on entering the background.
  46. }
  47. func sceneDidEnterBackground(_ scene: UIScene) {
  48. // Called as the scene transitions from the foreground to the background.
  49. // Use this method to save data, release shared resources, and store enough scene-specific state
  50. // information to restore the scene back to its current state.
  51. }
  52. }