Issue on iOS when pushing modal on master detail during application startup.

MikilllMikilll Member ✭✭✭
edited October 2018 in Xamarin.Forms

I have an unusual problem only appearing on iOS. After setting the main page (master detail) I am doing long asynchronous task. When this task is finished I am pushing modally another page like this:

MainPage = new MasterDetail();
await FetchSthFromDb();
MainPage.Navigation.PushModalAsync(new SomePage());

I got the following error:

Warning: Attempt to present <Xamarin_Forms_Platform_iOS_ModalWrapper: 0x7f9eb84694f0> on <Xamarin_Forms_Platform_iOS_PlatformRenderer: 0x7f9eb8444d80> whose view is not in the window hierarchy!

This error only appears on iOS. On Android everything is working fine. Did anyone encounter sth similar?

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
    edited October 2018

    Because MasterDetail is not placed inside Navigation stack , so it push modal on a navigation which does not exists.
    You can debug on the value of MainPage.Navigation to see if it is null.

    As a simple workaround , You can replace the MainPage with that new page .

    MainPage = new MasterDetail();
    await FetchSthFromDb();
    MainPage = new SomePage();
    

    Refer Xamarin.Forms Modal Pages

  • MikilllMikilll Member ✭✭✭
    edited October 2018

    @ColeX said:
    Because MasterDetail is not placed inside Navigation stack , so it push modal on a navigation which does not exists.
    You can debug on the value of MainPage.Navigation to see if it is null.

    As a simple workaround , You can replace the MainPage with that new page .

    MainPage = new MasterDetail();
    await FetchSthFromDb();
    MainPage = new SomePage();
    

    Refer Xamarin.Forms Modal Pages

    I don't think so :smile:

    It's a screen from the page which you have linked.

    BTW: My code works fine on Android. The problem exists only on iOS.

  • HelenMamalakiHelenMamalaki GBUniversity ✭✭
    edited March 7

    @Mikilll Did you find a work around for this? I'm am getting the same error...and works fine in Android but not in iOS. In my scenario, the user can tap a button on the MainPage to launch a native contact list picker, after selecting a contact, I want to navigate to a call page modally passing in the contact as a navigation parameter. But its just not navigating....I get the same warning in Application Output :( If I navigate non-modally it works fine.

Sign In or Register to comment.