Skip to content

Commit

Permalink
fix(iOS): CommandBar updates on navigation #3017
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpinedam committed Oct 17, 2020
1 parent b0be2c9 commit 48d1b0a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Uno.UI/Controls/CommandBarHelper.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if __IOS__
#if __IOS__
using System;
using System.Linq;
using Windows.UI.Xaml;
Expand Down Expand Up @@ -102,6 +102,16 @@ public static void PageDidDisappear(UIViewController pageController)
}
}

public static void PageWillDisappear(UIViewController pageController)
{
var topCommandBar = pageController.FindTopCommandBar();
if (topCommandBar != null)
{
// Set the native navigation bar to null so it does not render when the page is not visible
SetNavigationBar(topCommandBar, null);
}
}

private static CommandBar FindTopCommandBar(this UIViewController controller)
{
return (controller.View as Page)?.TopAppBar as CommandBar
Expand Down
13 changes: 13 additions & 0 deletions src/Uno.UI/Controls/NativeFramePresenter.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,19 @@ public override void ViewWillAppear(bool animated)
}
}

public override void ViewWillDisappear(bool animated)
{
try
{
base.ViewWillDisappear(animated);
CommandBarHelper.PageWillDisappear(this);
}
catch (Exception e)
{
Application.Current.RaiseRecoverableUnhandledException(e);
}
}

public override void ViewDidDisappear(bool animated)
{
try
Expand Down

0 comments on commit 48d1b0a

Please sign in to comment.