Swift 3 - loading multiple ViewControllers at launch

前端 未结 1 794
孤街浪徒
孤街浪徒 2021-01-25 01:40

I am working on making a tabbed app. It has a TabBarController and 4 ViewControllers attached to it.

By default, at launch only FirstViewController is loade

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-25 02:33

    Add in your main view controller

    var secondViewController:UIViewController!
    

    And in your viewDidLoad:

    secondViewController: UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "yourIdentifier") as! SecondViewController
    

    That's it. When you want to present it, use:

    self.present(secondViewController, animated: true, completion: nil)
    

    0 讨论(0)
提交回复
热议问题