I have been struggling with this issue for days and cannot get it to work. Read multiple SO posts (this, this, this, this, this and this). Asked my friend Google, helped to understand the problem but not to solve it yet.
In the first version of my iOS app (Swift2 and XCode7) I use a UITableViewController and UINavigationViewController to load new content from a different UIStoryboard. This all works fine. For the second version of this app I want to implement a UISplitViewController and now I am getting the error:
*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'adding a root view controller as a child of view controller:
I understand the hint, but cannot solve it in a way that works either in portrait and landscape mode. Moreover, the sort of solution I had did not use the UINavigationController in the landscape orientation.
I created a test project to track down this error, hoping to solve it.
This is the code that generates the error:
let storyboard = UIStoryboard(name: "ThirdScreen", bundle: nil)
let controller = storyboard.instantiateInitialViewController() as! ThirdDetailViewController
controller.title = "Miracle!"
splitViewController?.showDetailViewController(controller, sender: nil)
The full code of this test project is available from GitHub.
How can I make this work?
Thanks a lot!