In my UISplitViewController, the master view is a UINavigationController containing a UITableViewController. Sometime, when the user selects an item in the table, I have to push another tableViewController over the existing table in the master view.
In iOS 7, inside my first UITableViewController I just call
[self.navigationController pushViewController:otherTableVC animated:YES];
In iOS 8:
When the split view is collapsed, the otherTableVC becomes the detail View! Then after rotating the device, we see the two tables side by side...
Worse, if the device shows the two panes, the code works great and the second table is pushed over the first one in the master view. But, after a double rotation, the two tables are again side by side. It seems the collapsed mode of the UISplitViewController interferes with my own navigation controller...
How can I manage my own UINavigationController in the Master View?
Thank you
EDITED:
My both primary and details views have a navigation Controller. And to solve my problem, I just discovered that, in collapsed mode, I have to create an extra Navigation Controller and push it over the primary navigation controller.
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:otherTableVC];
[self.navigationController pushViewController:navController animated:YES];
So I just discovered hat we can push a navigation Controller inside another Navigation Controller.
Swift 4 Version with minor changes to make it work with my code:
Short answer, you can control this behaviour via the UISplitViewControllerDelegate methods:
I suspect what you really want to do is deal with the situation where you have an iOS 8 UISplitViewController-based app where your primary and detailed views are both UINavigationControllers and there are some viewControllers (within these navigation controllers) that you want to appear only on the primary or detail side of the split view. The answer below deals with this. It also copes with the situation where you sometimes wish for a view to replace the views in the Detail navigation controller, rather than getting pushed there.
A small caveat: the code below does not deal with all possible cases and has some assumptions:
I don't recommend implementing only one side of the splitViewController:collapseSecondaryViewController:ontoPrimaryViewController: / splitViewController: separateSecondaryViewControllerFromPrimaryViewController: logic and depending on the default implementation for the other side. Apple do some strange things like putting the UINavigationViewController from the Detail side into the primary side as one of the viewControllers in the Primary navigation controller stack but then pushing other view controllers above it, which even if you understand completely still can't be replicated from your own code. Thus its best to handle both sides of the process yourself.
This is what I use: