Skip to content

Instantly share code, notes, and snippets.

@LearnWithTung
Last active March 22, 2021 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LearnWithTung/9f88fa8acb20b5bfc16b908776057d20 to your computer and use it in GitHub Desktop.
Save LearnWithTung/9f88fa8acb20b5bfc16b908776057d20 to your computer and use it in GitHub Desktop.
class SceneDelegate {
var navigationController: UINavigationController!
...
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let sceneWindow = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: sceneWindow)
window?.makeKeyAndVisible()
navigationController = UINavigationController(rootViewController: makeRootViewController())
window?.rootViewController = navigationController
}
func makeRootViewController() -> UIViewController {
let viewControllerA = ...
viewControllerA.onButtonTappedObserve = {
let viewControllerB = storyboard!.instantiateViewController(identifier: "ViewControllerB")
navigationController.pushViewController(viewControllerB, animated: true)
}
return viewController A
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment