Last active
March 22, 2021 07:51
-
-
Save LearnWithTung/9f88fa8acb20b5bfc16b908776057d20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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