您好我正在尝试从UiViewController呈现UiSplitViewController。我正在UiViewController中进行一些搜索,并根据结果显示UiSplitViewController。我怎么能以编程方式做到这一点?到目前为止,我在google搜索后尝试了3种方法
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
上述方法都没有奏效,我该如何解决这个问题。谢谢。
答案 0 :(得分:1)
让mainStoryboard:UIStoryboard = UIStoryboard(名称:" Main",bundle:nil)
let viewController = mainStoryboard.instantiateViewController(withIdentifier: "SplitView") as! UISplitViewController
UIApplication.shared.keyWindow?.rootViewController = viewController
您必须设置根视图控制器