views:

449

answers:

3

I'm having a hard time understanding why the following is happening (and how to fix it).

I've created an application using the split-view based application.

I've added a UiBarButtonItem called showTheModal which calls this method found in RootViewController.m:

- (IBAction)showTheModal:(id)sender {
theModalController.modalPresentationStyle = UIModalPresentationFullScreen;
theModalController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:theModalController animated:YES];

if ([detailViewController popoverController] != nil)
    [[detailViewController popoverController] dismissPopoverAnimated:YES];

The BarButtonItem of course, is shown at the bottom of the Default Root Controller (left side of the of the split view in landscape) or at the bottom of the popup (if in landscape).

The modal view is dismissed by a button placed in a toolbar. It calls the following:

[self dismissModalViewControllerAnimated: YES];

The problem I'm having is if rotate the screen, while the modal is up. Here is what happens in different scenarios (start refers to the orientation when the showTheModal button is hit, end refers to the orientation when I hit the dismissModal button).

1)Start landscape, end landscape: Everything appears fine. willHideViewController and willShowViewController methods are not called in the RootViewController (as expected)

2) Start landscape, end portrait: UI appears fine. willHideViewController is run TWICE (WHY?)

3) Start portrait, end portrait: UI appears fine. willHideViewController is run once (as expected)

4) Start portrait, end landscape: The 'Root List' button remains in the detail view (right side of the split view. Neither willHideViewController and willShowViewController are invoked (WHY??)

Any thoughts as to why #2 and #4 don't behave quite the expected way?

A: 

For diagnostics, have you tried dismissing the popover view first? Or logging who is calling the method by printing (id) sender?

JoePasq
A: 

I've had exactly the same problem (#4, above). I worked around it using viewDidAppear:animated, and then checking the height of the view to see if it is in landscape vs. portrait. (Yuck, gag, etc.) I'm not satisfied at all with that "solution".

Possibly related: I've noticed that the button in portrait mode is slow to disappear after rotating to landscape, i.e. the button appears for a second after the rotation finishes. However, in Mail.app, the "Inbox" button disappears as soon as the rotation starts. Is Apple doing things differently than they recommend in their docs? Perhaps there is a more efficient way to show/hide the master view button?

Jamis Buck
A: 

I think that this is a bug that needs to be reported to Apple Development.

I worked around part of this issue by presenting my modal view using the UIModalPresentationPageSheet format.

CodeSpyder