swift set initial view controller

// For Swift 4.2 and 5 code:

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
     self.window = UIWindow(frame: UIScreen.main.bounds)

     let storyboard = UIStoryboard(name: "Main", bundle: nil)

     let initialViewController = storyboard.instantiateViewController(withIdentifier: "dashboardVC")

     self.window?.rootViewController = initialViewController
     self.window?.makeKeyAndVisible()
}

// For Xcode 11+ and for Swift 5+ :

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

     var window: UIWindow?

     func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
         if let windowScene = scene as? UIWindowScene {
             let window = UIWindow(windowScene: windowScene)

              window.rootViewController = // Your RootViewController in here

              self.window = window
              window.makeKeyAndVisible()
         }
    }
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
hwo to set initial view controller in ios how to set a view controller as initial view controller in swift how to initialize view controller in swift swift page view controller set initial change initial view controller programmatically swift create settings view controller swift swift default initializer for a view controller swift when is the default view controller class initialized swift when is view controller initialized initialize view controller programmatically swift swift initialize view controller programmatically how to initialize a view controller swift how to set initial view controller swift first screen swift swift change view controller set root view controller programmatically appdelegate swift set navigation controller in appdelegate swift explicitly define initial view controller app delegate hot to set default root in app-delegate in swift how to change main view swift appdelegate window rootviewcontroller swift appdelegate redirect in store how to intail screen in swift programticlly set initial navigation controller programmatically swift set initial view controller programmatically swift 5 appdelegate to first viewcontroller change first view controller swift how to set the first view controller of app, swift change initial view controller programmatically swift 4 swift change initial controller how to change the root view controller appdelegate in swift how to change the root view controller appdelegte in swift how to change the root view controller appdelegae in swift swift change root view of appdelegate change dafault storyboard swift appdelegate swift 5 appdelegate window uiwindow set initial screen in swift tuto swift set the initial viewcontroller swift set initial view controller
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source