presentViewController:animated:completion display issues in new ios 5.1 UISplitViewController

10,790

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];
Share:
10,790
myieh
Author by

myieh

Updated on June 04, 2022

Comments

  • myieh
    myieh almost 2 years

    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.

    • Hubert Kunnemeyer
      Hubert Kunnemeyer about 12 years
      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.
  • Setomidor
    Setomidor over 11 years
    Doesn't work for me, the new view then ends up in the "detail" view only.
  • whyoz
    whyoz about 11 years
    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