Bug 25892 - On iPads, MasterDetailPage.IsPresented has problems.
Summary: On iPads, MasterDetailPage.IsPresented has problems.
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-09 15:34 UTC by Kevin.Murray
Modified: 2018-03-21 14:05 UTC (History)
13 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Kevin.Murray 2015-01-09 15:34:59 UTC
On iPad devices (iPod, iPhone seem OK):

If you have a MasterDetailPage and set

MasterBehavior = Xamarin.Forms.MasterBehavior.Popover;

You can set 

IsPresented = true;

to show the Master page.  If you try to hide it, however:

IsPresented = false;

Nothing happens.  Master stays showing.  

If your Detail page then has a NavigationPage of its own that is displayed, you will crash with a strange error:

"MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[UIPopoverController _presentPopoverBySlidingIn:fromEdge:ofView:animated:stateOnly:notifyDelegate:]: Popovers cannot be presented from a view which does not have a window."

So, in my application I use the MasterDetailPage for the primary interaction.  When a user needs to log in, the MasterDetailPage overrides OnAppearing():

public class MainPage : MasterDetailPage
{
    protected override void OnAppearing()
    {
        if( !loginValid )
        {
            IsPresented = false;
            Navigation.PushModalAsync( new NavigationPage( new LoginPage() ) );
        }
        base.OnAppearing();
    }
}

Where LoginPage is just a ContentPage with controls on it.  The Master page has a menu choice for "Log Out," which will clear out some data, and set the "loginValid" to false.  But, the Master page never slides back out of the view.  If you attempt to tap on the visible parts of the LoginPage, the application crashes with the aforementioned error.
Comment 1 Indira 2015-01-16 06:35:38 UTC
I am also facing the same problem on iPad2. Please suggest fix or any workaround.
Comment 2 Daniel Münch 2015-01-21 10:11:01 UTC
Having the same problem here with the exact same Exception. Please suggest fix or workaround.
Comment 3 Ian 2015-01-26 17:50:15 UTC
I can confirm I get the same error
Comment 4 Ian 2015-01-26 17:55:29 UTC
If you rotate the ipad a bunch of times, hiding and showing the MasterPage slide out, then try, the error does not happen.

It's like it needs to be warmed up.
Comment 5 Gavin F 2015-01-27 14:35:32 UTC
I can confirm I am seeing the same issue.  Forms 1.3.1 on iOS, using a MasterDetailPage with a navigation controller as the detail page. Unable to explicitly close the Master view in code using IsPresented = false.  I am attempting to launch a facebook login webview from the Master, page appears, but master does not close.  Clicking on webview crashes app.
Comment 6 Rui Marinho 2015-01-29 12:15:12 UTC
Can you try with 1.3.2-pre2 and see if it fixes your problem ? 

Thanks.
Comment 7 Ian 2015-01-29 12:21:26 UTC
FIXED.
Comment 8 Gavin F 2015-01-29 14:13:28 UTC
Fixed the IsPresented = false issue.  Thank you!
Comment 9 Mayank Agrawal 2015-07-07 05:53:59 UTC
I am also having the same problem. My Xamarin.Forms version is xamarin.forms 1.4.3.6374. Now what to do...Kindly help me
Comment 10 mina 2018-03-21 14:05:00 UTC
I still have the same issue with Xamarin.Forms 2.5.0.280555 
iPad only 

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController _presentPopoverBySlidingIn:fromEdge:ofView:animated:stateOnly:notifyDelegate:]: Popovers cannot be presented from a view which does not have a window.'

any luck to fix this issue