1
votes

When I navigate to a page that uses a flow of NavigationPage.Navigation.InsertPageBefore(ContentPage) then NavigationPage.PopAsync().ConfigureAwait(false) the toolbar item on the global navigation page disappears but when using push/pop the tool bar always remains. This only happens on iOS.

The navigation page is a global scoped to the app level along with a master detail page in which the navigation page serves as the detail portion.

Add ToolbarItem

var toobaritemMenu = new ToolbarItem
 {
     Icon = "Screenshot",                                   
     Command = new Command(() => Device.BeginInvokeOnMainThread(() => App.MasterNavigation.PushAsync(new ContentPage(), false)))
 };
 App.MasterNavigation.ToolbarItems.Add(toobaritemMenu);

Moving to a Page Like This Causes Toolbar Item to Disappear on iOS

Device.BeginInvokeOnMainThread(() => App.MasterNavigation.Navigation.InsertPageBefore(new ContentPage(), App.MasterNavigation.CurrentPage));
Device.BeginInvokeOnMainThread(() => App.MasterNavigation.PopAsync().ConfigureAwait(false));

Is there a reason for this as it seems inconsistent since it works on Android.

1

1 Answers

3
votes

I ran into the same issue. My workaround was to change how I was manipulating the navigation stack: instead of inserting the new page and popping off the current page, push the new page onto the stack and then remove the current one:

await currentPage.Navigation.PushAsync(nextPage, animated: true);
currentPage.Navigation.RemovePage(currentPage);

You end up with the same final navigation stack, but it avoids whatever issue is causing the problem with the secondary toolbar items in iOS.