Forcing MainPage to Not Be Wrapped in a NavigationPage, and Still Support Navigation

NPCNPC USMember ✭✭

I've been caught in quite the pickle with the iPad implementation of my app.

I've got a MasterDetailPage. The Detail Page is a TabbedPage, the Master Page is a page containing a StackLayout with buttons.

This Works fine for Android and most iOS devices, however any link within the Master Page causes the app to crash with an NSInvalidArgumentException.

The best description of this problem is by @adamkemp here: https://forums.xamarin.com/discussion/comment/107216/#Comment_107216

It boils down to the implementation on the iPad does not want to work with a MasterDetailPage nested within a NavigationPage. However if I change the implementation to have the MasterDetailPage not nested within the NavigationPage, then I am unable to push a new Page and get an error along the lines of "PushAsync is not supported globally on iOS, please use a NavigationPage"

Kinda between a rock an a hard place with this

Tagged:

Best Answer

  • NPCNPC US ✭✭
    Accepted Answer

    I've mostly solved this. Pushing Modal pages can be achieved without this error being thrown. Not sure why. Alternatively on navigation you can set a new MainPage Push from that. Then play with the NavigationStack to place your page where it should be, which tends to stack the NavigationBar. Or reset the MainPage on leaving. The latter solutions are incredibly janky however.

Answers

  • NPCNPC USMember ✭✭
    Accepted Answer

    I've mostly solved this. Pushing Modal pages can be achieved without this error being thrown. Not sure why. Alternatively on navigation you can set a new MainPage Push from that. Then play with the NavigationStack to place your page where it should be, which tends to stack the NavigationBar. Or reset the MainPage on leaving. The latter solutions are incredibly janky however.

Sign In or Register to comment.