【Swift】起動時にStoryboardIDで画面を分岐
どうも、ねこきち(@nekokichi1_yos2)です。
初回起動、もしくはログイン状態で表示する画面を分岐する処理を備忘録として書き残します。
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { let windows = UIWindow(windowScene: scene as! UIWindowScene) self.window = windows windows.makeKeyAndVisible() let sb = UIStoryboard(name: "Main", bundle: Bundle.main) if 条件式 { let vc = sb.instantiateViewController(withIdentifier: ストーリーボードID) window!.rootViewController = vc } else { let vc = sb.instantiateViewController(withIdentifier: ストーリーボードID) window!.rootViewController = vc } }
参考