Skip to content

Commit

Permalink
fix: avoid calling Native getter in NativeCommandBarPresenter
Browse files Browse the repository at this point in the history
  • Loading branch information
kazo0 committed Dec 4, 2023
1 parent c56e433 commit e9c011d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/Uno.UI/Controls/CommandBar/NativeCommandBarPresenter.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,28 @@ private protected override void OnLoaded()
_commandBar = new WeakReference<CommandBar?>(commandBar);
}

if (commandBar?.TryGetRenderer<CommandBar, CommandBarRenderer>() is { } commandBarRenderer)
if ((commandBar?.TryGetNative<CommandBar, CommandBarRenderer, UINavigationBar>(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);


var commandBarItemRenderer = new CommandBarNavigationItemRenderer(commandBar);
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);
}
}

Expand Down

0 comments on commit e9c011d

Please sign in to comment.