SceneDelegate.swift 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 UIWindowScene `scene`.
  21. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
  22. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
  23. guard let _ = (scene as? UIWindowScene) else { return }
  24. }
  25. func sceneDidDisconnect(_ scene: UIScene) {
  26. // Called as the scene is being released by the system.
  27. // This occurs shortly after the scene enters the background, or when its session is discarded.
  28. // Release any resources associated with this scene that can be re-created the next time the scene connects.
  29. // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
  30. }
  31. func sceneDidBecomeActive(_ scene: UIScene) {
  32. // Called when the scene has moved from an inactive state to an active state.
  33. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
  34. }
  35. func sceneWillResignActive(_ scene: UIScene) {
  36. // Called when the scene will move from an active state to an inactive state.
  37. // This may occur due to temporary interruptions (ex. an incoming phone call).
  38. }
  39. func sceneWillEnterForeground(_ scene: UIScene) {
  40. // Called as the scene transitions from the background to the foreground.
  41. // Use this method to undo the changes made on entering the background.
  42. }
  43. func sceneDidEnterBackground(_ scene: UIScene) {
  44. // Called as the scene transitions from the foreground to the background.
  45. // Use this method to save data, release shared resources, and store enough scene-specific state information
  46. // to restore the scene back to its current state.
  47. }
  48. }