Forked from pavankataria/scene-delegates-programmatic-window-creation.swift
Created
December 28, 2023 06:05
-
-
Save munho/97a16ce3585b798e46f79ffd7e94401d 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
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
/// 1. Capture the scene | |
guard let windowScene = (scene as? UIWindowScene) else { return } | |
/// 2. Create a new UIWindow using the windowScene constructor which takes in a window scene. | |
let window = UIWindow(windowScene: windowScene) | |
/// 3. Create a view hierarchy programmatically | |
let viewController = ArticleListViewController() | |
let navigation = UINavigationController(rootViewController: viewController) | |
/// 4. Set the root view controller of the window with your view controller | |
window.rootViewController = navigation | |
/// 5. Set the window and call makeKeyAndVisible() | |
self.window = window | |
window.makeKeyAndVisible() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[iOS] AppDelegate와 SceneDelegate
Deployment Target이 iOS 13 미만인 상황에서는?