The premise is remarkably simple: I want to display a modal view in an iPad app that uses a UISplitViewController.
The view hierarchy is straight-forward:
/- TableViewController1
/- root:TabBarController -- TableViewController2
SplitViewController -
\- detail:CustomViewController
When I click on one of the table cells in TableViewController1, I open a modal view:
- (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)ip {
UIViewController *vc = [[MyModalClass alloc] init];
UINavigationController *nc = [[UINavigationController alloc]
initWithRootViewController:vc];
nc.modalPresentationStyle = UIModalPresentationFormSheet;
nc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:nc animated:true];
[nc release];
[vc release];
}
This works just fine: the view appears. The problems start when I try to dismiss it in any orientation other than landscape.
In ModalViewController, the following method is triggered by a UITabBarButton in the navigation bar:
- (void) closeButtonInNavBarWasClicked:(id)sender {
[self dismissModalViewControllerAnimated:true];
}
And THIS is where the problems start.
When this code is called, the modal view disappears, BUT: the TabBarController (the split view's root view) is suddenly rotated and resized. The content is suddenly sideways, and partially covers the details view. The details view isn't resized to be smaller, it's just partially covered by the root view.
The only situation where this problem doesn't appear is when I tap on the TableViewController1 cell when the app is in portrait mode. Despite the root view being in a popover (which could be an ample source of bugs), everything works fine.
Some things I have already tried, with no success:
- Dump the tab bar, just display TableViewController1 as the root controller of the split view
- Create a delegate protocol so that the parent TableViewController1 dismisses the modal view rather than the MyModalClass view itself.
- Presenting/dismissing the modal view on TableViewController1.splitViewController actually makes things worse: the view doesn't even appear.
- Sacrificing several goats also did not help.
I would hugely appreciate any input on this issue.