Last active
October 21, 2023 18:35
-
-
Save Toni77777/d38e3aa5f5cd4d0b7c2ae892ab161840 to your computer and use it in GitHub Desktop.
Set rootViewController in SceneDelegate (Since iOS 13 and Xcode 11)
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: UIResponder, UIWindowSceneDelegate { | |
var window: UIWindow? | |
func scene(_ scene: UIScene, | |
willConnectTo session: UISceneSession, | |
options connectionOptions: UIScene.ConnectionOptions) { | |
// Get UIWindowScene | |
guard let windowScene = (scene as? UIWindowScene) else { | |
return | |
} | |
// Create a new window property | |
self.window = UIWindow(frame: windowScene.coordinateSpace.bounds) | |
// Set windowScene for window | |
self.window?.windowScene = windowScene | |
// Set custom LoginViewController as root | |
window?.rootViewController = LoginViewController() | |
// Present the window | |
window?.makeKeyAndVisible() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment