From e9c011d2a5ebc0cbe4250906c8edd184ca79e3ba Mon Sep 17 00:00:00 2001 From: Steve Bilogan Date: Mon, 4 Dec 2023 08:09:47 -0500 Subject: [PATCH] fix: avoid calling Native getter in NativeCommandBarPresenter --- .../NativeCommandBarPresenter.iOS.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Uno.UI/Controls/CommandBar/NativeCommandBarPresenter.iOS.cs b/src/Uno.UI/Controls/CommandBar/NativeCommandBarPresenter.iOS.cs index 48b302abdf41..e730d7a21e17 100644 --- a/src/Uno.UI/Controls/CommandBar/NativeCommandBarPresenter.iOS.cs +++ b/src/Uno.UI/Controls/CommandBar/NativeCommandBarPresenter.iOS.cs @@ -41,16 +41,14 @@ private protected override void OnLoaded() _commandBar = new WeakReference(commandBar); } - if (commandBar?.TryGetRenderer() is { } commandBarRenderer) + if ((commandBar?.TryGetNative(out var nativeBar) ?? false) + && nativeBar is { }) { - if (commandBarRenderer.Native is { } nativeBar) - { - LayoutNativeBar(nativeBar); - } + LayoutNativeBar(nativeBar); } else if (commandBar is { } && FeatureConfiguration.CommandBar.AllowNativePresenterContent) { - commandBarRenderer = new CommandBarRenderer(commandBar); + var commandBarRenderer = new CommandBarRenderer(commandBar); commandBar.SetRenderer(commandBarRenderer); @@ -58,13 +56,13 @@ private protected override void OnLoaded() commandBar.SetRenderer(commandBarItemRenderer); var navigationItem = new UINavigationItem(); - var nativeBar = new UINavigationBar(); - nativeBar.PushNavigationItem(navigationItem, false); + var navBar = new UINavigationBar(); + navBar.PushNavigationItem(navigationItem, false); commandBarItemRenderer.Native = navigationItem; - commandBarRenderer.Native = nativeBar; + commandBarRenderer.Native = navBar; - LayoutNativeBar(nativeBar); + LayoutNativeBar(navBar); } }