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.
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];
来源:https://stackoverflow.com/questions/9831486/presentviewcontrolleranimatedcompletion-display-issues-in-new-ios-5-1-uisplitv