Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

"Popovers cannot be presented from a view which does not have a window." when in full screen modal #31

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

I found a bug when playing a mpmovieplayerviewcontroller inside a full screen modal.
Line 578 of mgsplitviewcontroller.m reads:
[_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];

but this causes a crash if self.view is not attached to a window.

So I added
if (self.view.window != nil) before that line and that worked.

I meet this problem in my problem, and can u tell me why? What does this " if (self.view.window != nil) " do to the program? The popover shows always, when add this line, but if not add this line, the self.view.window sometimes to be nil.

cduhn commented May 30, 2011

I encountered this same bug in a case where I start in portrait orientation, push a full-screen media player, rotate to landscape, and dismiss the media player.

At first I tried the same fix (if (self.view.window != nil)), but I found that it "leaves masterViewController's views in disarray", as Matt mentioned in his comment above that line. Specifically it left masterViewController's navigationBar sized for the wrong orientation. Here's an alternate fix that worked better for me: Change self.view to [[UIApplication sharedApplication] keyWindow]. So the full line reads:

    [_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:[[UIApplication sharedApplication] keyWindow] permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];

Thank you for your comment. I will fix that line according to your suggestion (and close the pull request, by the way).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment