2

I've ran into some problems using UISplitViewController with presentViewController:animated:completion.

To break the problem down into its simplest form, I've created a simple project with the master/detail template. In the project I've added a + button in the navigation bar of the master view. The plus button creates a navigation controller with a simple blank view. This navigation controller is then presented using presentViewController:animated:completion. However, the presented view only displays in the master view and when you dismiss it, the master view takes up the whole screen. I can't seem to understand what is going on. Anyone else encountered this problem? Here's the code.

- (void)showViewController:(id)sender
{
LMTestViewController *masterView = [[LMTestViewController alloc] init];
[self presentViewController:masterView animated:YES completion:nil];
[masterView release];
}

Thanks for your help.

drew010
  • 68,777
  • 11
  • 134
  • 162
myieh
  • 79
  • 1
  • 1
  • 5
  • A master/detail is a navigationControler both in the detail view and the masterView Controllers. You really can't put a NavigationController in another NavigationController. The View Hierarchy can get confused. Try presenting it Modally if you want a different navigationController. – Hubert Kunnemeyer Mar 23 '12 at 03:56

1 Answers1

6

To present modally, use the window's root view controller. Using anything else will cause things to become confused in the split view, especially when rotating, etc.

[self.view.window.rootViewController presentViewController:masterView
                                                  animated:YES
                                                completion:NULL];
Allan Bazinet
  • 1,752
  • 15
  • 15
  • Doesn't work for me, the new view then ends up in the "detail" view only. – Setomidor Dec 07 '12 at 13:36
  • Any updates on this issue? I'm presenting in the same way, and then resizing the view into a container UIView...it resizes correctly then eventually crashes after reloading the detailView – whyoz Mar 08 '13 at 00:06