How to set initial storyboard

后端 未结 2 720
鱼传尺愫
鱼传尺愫 2020-12-18 07:32

I have two storyboards one of them is default called Main and the other one I have just added is called Admin.

Main

2条回答
  •  我在风中等你
    2020-12-18 07:47

    You can set your storyboard programmatically like this in the app delegate:

    window = UIWindow(frame: UIScreen.main.bounds)
    // Or "Admin"
    window!.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()! 
    window!.makeKeyAndVisible()
    

    You could actually set any view controller. That's how no-storyboard approach is wired up.

    Oh, another advantage of doing it in code is it delays the storyboard initialization. If you use the "Main Interface" settings in Xcode, the storyboard is actually initialized BEFORE the application:didFinishLaunchingWithOptions method.

提交回复
热议问题