I have a split view controller in landscape mode with two navigation controllers.
This collapses to a single navigation controller in portrait and the detail view controller is pushed from the master.
If I rotate back to landscape when the detail view controller is pushed in portrait I don't understand how to put the detail view controller back into it's own navigation controller.
You should implement UISplitViewControllerDelegate. Simplest way may be to have your own MySplitViewController class and set itself as a delegate in viewDidLoad:
self.delegate = self;
First, you may want showDetailViewController to look something like:
- (BOOL) splitViewController:(UISplitViewController*)splitViewController showDetailViewController:(UIViewController*)vc sender:(id)sender
{
if (splitViewController.collapsed)
{
[(UINavigationController*)splitViewController.viewControllers[0]) pushViewController:vc animated:YES];
}
else
{
self.viewControllers = @[ self.viewControllers.firstObject, vc ];
}
return YES;
}
That should take care of proper showing of details view in both orientations.
Next, you should implement following delegate method similar to this:
- (UIViewController*) splitViewController:(UISplitViewController*)splitViewController
separateSecondaryViewControllerFromPrimaryViewController:(UIViewController*)primaryViewController
{
UINavigationController* nc = primaryViewController;
UIViewController* detailVC = nc.viewControllers.lastObject;
return detailVC;
}
This method is your chance to take whatever you want from primary controller and return that as detail view controller. The example code above is rather simple one, you may need to traverse through navigation viewControllers and pick all starting from specific view controller (assuming you had pushes from details view).
Anyways, it would really payoff to take some time and read: UISplitViewController class reference and especially UISplitViewControllerDelegate Protocol Reference This will be much clearer. If you want a shortcut, take a look at Xcode split view controller template project. That one should also contain hint or exact solution for your problem.