1

Hi I'm trying to present UiSplitViewController from UiViewController. I'm doing some search in UiViewController and based on result I display UiSplitViewController. How can I do it programatically? So far I tried 3 methods after googling

1.self.performSegue(withIdentifier: "SearchComplete", sender: self)

2.self.present(PrimarySplitViewController(), animated: true, completion: nil)

3.let detailViewController = self.storyboard?.instantiateViewController(withIdentifier: "SplitView") as! UISplitViewController self.splitViewController?.viewControllers[1] = detailViewController

None of the above methods have worked how can I solve this. Thank you.

e.k
  • 1,333
  • 1
  • 17
  • 36

1 Answers1

1

let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

    let viewController = mainStoryboard.instantiateViewController(withIdentifier: "SplitView") as! UISplitViewController

    UIApplication.shared.keyWindow?.rootViewController = viewController 

You have to set root view controller

Karthik
  • 381
  • 2
  • 10