rid00z / FreshMvvm

FreshMvvm is a super light Mvvm Framework designed specifically for Xamarin.Forms. It's designed to be Easy, Simple and Flexible.
Apache License 2.0
596 stars 172 forks source link

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

Open bgaprogrammer opened 4 years ago

bgaprogrammer commented 4 years ago

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 commented 4 years ago

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