UIStoryboard load from app delegate

前端 未结 4 1411
情歌与酒
情歌与酒 2021-01-11 13:24

I am trying to load a UIStoryboard from the app delegate .m in this way:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDi         


        
4条回答
  •  时光取名叫无心
    2021-01-11 13:41

    For Swift 4.2 and higher.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)
        let storyboard = UIStoryboard(name: "YourStoryboardName", bundle: Bundle.main)
        let viewController = storyboard.instantiateInitialViewController()
        window?.rootViewController = viewController
        window?.makeKeyAndVisible()
        return true
    }
    

提交回复
热议问题