LoginSignup
32
37

More than 5 years have passed since last update.

起動時のViewControllerを動的に変更する

Last updated at Posted at 2015-01-21

ViewControllerにIDを設定

初回起動時の候補のViewControllerにIDを設定
スクリーンショット 2015-01-21 18.09.18.png

AppDelegateに分岐処理を記述

処理をappDelegateに記述


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        var flg = true //分岐条件

        var storyboard:UIStoryboard =  UIStoryboard(name: "Main",bundle:nil)
        var viewController:UIViewController


        //表示するビューコントローラーを指定
        if  flg {
            viewController = storyboard.instantiateViewControllerWithIdentifier("firstViewController") as UIViewController
        } else {
            viewController = storyboard.instantiateViewControllerWithIdentifier("secondViewController") as UIViewController
        }


        window?.rootViewController = viewController

        return true
}

参考

リンク起動時に表示する ViewController を動的に変更する

32
37
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
37