Snippet for my video No Storyboards
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: UIScreen.main.bounds)
let vc = ViewController()
let navVC = UINavigationController(rootViewController: vc)
window?.rootViewController = navVC
window?.makeKeyAndVisible()
window?.windowScene = windowScene
}
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
UIWindowScene * windowScene = (UIWindowScene*) scene;
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ViewController* initialViewController = [[ViewController alloc] init];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:initialViewController];
_window.rootViewController = navController;
[_window makeKeyAndVisible];
_window.windowScene = windowScene;
}