Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 13.4 ModalPresentationStyle is Fullscreen instead of PageSheet when navigating to a modal page #306

Open
bgaprogrammer opened this issue Apr 15, 2020 · 1 comment

Comments

@bgaprogrammer
Copy link

bgaprogrammer commented Apr 15, 2020

I'm facing a very strange behavior with modal navigation, in brief, the modal pages are shown in FullScreen instead of Automatic (PageSheet).

I understand that by default in iOS 13+ the default ModalPresentationStyle is setted to Automatic which internally is translated to PageSheet and that is the behavior I expect when navigating to a modal page, but that is not happening in my App.

This behavior is very strange, I've traced the problem creating a NavigationRenderer, basically there I'm handling the WillMoveToParentViewController(UIViewController parent) event.

The first time the event is triggered (when showing the MainPage) the value for parent.ModalPresentationStyle is UIModalPresentationStyle.PageSheet as expected, but the second time (when I launch the navigation to a modal page) it has changed to UIModalPresentationStyle.FullScreen

I'm not really sure if this is a bug or something I'm doing wrong, but as this is happening when navigating I think maybe here someone could provide me some guidance.

My Setup:

My 3 projects (Shared, Android and iOS) all are using latest (at this time) Xamarin.Forms package which is 4.5.0.617 and in the shared (.net standard) project I'm referencing latest nuget package for FreshMvvm 3.0.0.

For testing and reproducing this I'm using only devices and simulators running iOS 13.4 and 13.4.1, mainly iPhone 11 and PRO MAX.

A short version of my code here:

App.xaml.cs

public App()
{
  InitializeComponent();

  var loginPage = FreshPageModelResolver.ResolvePageModel<LoginPageModel>();
  var loginNavContainer = new FreshNavigationContainer(loginPage);

  MainPage = loginNavContainer;
}

LoginPageModel.cs

private async void DoSomething()
{
    try
    {
        //my logic
    }
    catch (Exception e)
    {
      //This page is presented with FullScreen style
      await CoreMethods.PushPageModel<ErrorPageModel>(null, true); 
    }
}

NavigationPageRenderer.cs

public class NavigationPageRenderer : NavigationRenderer
{
    public override void WillMoveToParentViewController(UIViewController parent)
    {
        if(parent != null)
        {
            parent.ModalPresentationStyle = UIModalPresentationStyle.Automatic;
        }
    }
}

My not-so-fancy fix is to use the NavigationRenderer to change the Style on the fly (and works!), but I would like to understand what is really happening here.

Note: This "error" is even happening with the Sample App attached here in the repo.

@Robbert-jansen
Copy link

I've just noticed the same thing, quite annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants