How do I present a controller from appDelegate?

How do I present a controller from appDelegate?

The steps are as follows:

  1. Create an instance of UIStoryboard, let mainStoryboard:UIStoryboard = UIStoryboard(name: “Main”, bundle: nil)
  2. Instantiate View Controller with Identifier, HomeViewController.
  3. Set the Root View Controller of your app’s window to a different one. rootViewController = homePage.

How do I change initial view controller programmatically?

Programmatically Changing the Initial View Controller

  1. Clear the value of your program’s Main Storyboard File Base Name.
  2. Clear the value of Main Interface in your app’s General tab.
  3. In your app’s delegate’s application:didFinishLaunchingWithOptions: method: create the new Initial View Controller.

How do I get to rootViewController in appDelegate?

How to get root view controller?

  1. Objective-C YourViewController *rootController = (YourViewController*)[[(YourAppDelegate*) [[UIApplication sharedApplication]delegate] window] rootViewController];
  2. Swift let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate let viewController = appDelegate.window!.

How do I get root view controller?

The root view controller is simply the view controller that sits at the bottom of the navigation stack. You can access the navigation controller’s array of view controllers through its viewControllers property. To access the root view controller, we ask for the first item of the array of view controllers.

What is Uiscene?

An object that represents one instance of your app’s user interface.

Is initial view controller a storyboard?

Every storyboard file has an initial view controller that represents the default view controller to create. Typically, you use the initial view controller as the root view controller for a window. However, you can also instantiate the initial view controller when transitioning to content in a new storyboard file.

How do I set initial view in SwiftUI?

2 Answers. change the line let contentView = ContentView()… to YourInitialView()… You can not use UIViewController with SwiftUI, In SwiftUI Views are Struct.

How do I access rootViewController?

How do I get rootViewController of Uinavigationcontroller?

How to get root view controller?

  1. UIViewController *rootViewController = (UIViewController*)[[[UIApplication sharedApplication] keyWindow] rootViewController];
  2. NSArray *viewControllers = self. navigationController. viewControllers;
  3. UIViewController *root = (UIViewController*)[self. navigationController.

What is Uiwindow in Swift?

The backdrop for your app’s user interface and the object that dispatches events to your views.