SceneDelegate.swift 3.2 KB

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