Skip to content

Commit

Permalink
fix(iOS): CommandBar updates on navigation unoplatform#3017
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpinedam committed Oct 22, 2020
1 parent daa13d9 commit af732b9
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__
#nullable enable
using System;
using System.Linq;
Expand Down Expand Up @@ -101,6 +101,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 af732b9

Please sign in to comment.