Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ protected virtual void OnRendererSet()
ViewController.AutomaticallyAdjustsScrollViewInsets = false;
}
}

internal void UpdateTitleViewInternal()
{
UpdateTitleView();
}

protected virtual void UpdateTitleView()
{
Expand All @@ -279,6 +284,13 @@ protected virtual void UpdateTitleView()
return;
}

if ((OperatingSystem.IsIOSVersionAtLeast(26) || OperatingSystem.IsMacCatalystVersionAtLeast(26)) && ViewController?.NavigationController is null)
{
// If we are on iOS 26+ and the ViewController is not in a NavigationController yet,
// we cannot set the TitleView yet as it would not layout correctly.
return;
}

var titleView = _context?.Shell?.Toolbar?.TitleView as View;

if (NavigationItem.TitleView is TitleViewContainer tvc &&
Expand Down Expand Up @@ -497,7 +509,7 @@ void UpdateLeftToolbarItems()
// We only check height because the navigation bar constrains vertical space (44pt height),
// but allows horizontal flexibility. Width can vary based on icon design and content,
// while height must fit within the fixed navigation bar bounds to avoid clipping.

// if the image is bigger than the default available size, resize it

if (icon is not null && originalImageSize.Height - defaultIconHeight > buffer)
Expand Down Expand Up @@ -736,7 +748,7 @@ internal TitleViewContainer(View view, CGRect navigationBarFrame) : this(view)
// Set frame to match navigation bar dimensions, starting at origin (0,0)
// The X and Y are set to 0 because this view will be positioned by the navigation bar
Frame = new CGRect(0, 0, navigationBarFrame.Width, navigationBarFrame.Height);
Height = navigationBarFrame.Height; // Set Height for MatchHeight logic
Height = navigationBarFrame.Height; // Set Height for MatchHeight logic
}

public override CGRect Frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,13 @@ public override void WillShowViewController(UINavigationController navigationCon
tracker is ShellPageRendererTracker shellRendererTracker)
{
shellRendererTracker.UpdateToolbarItemsInternal(false);
if (OperatingSystem.IsIOSVersionAtLeast(26) || OperatingSystem.IsMacCatalystVersionAtLeast(26))
{
// If we are on iOS 26+ and the ViewController is not in a NavigationController yet,
// we cannot set the TitleView yet as it would not layout correctly.
// So we update it later when the ViewController is added to the NavigationController
shellRendererTracker.UpdateTitleViewInternal();
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue32899.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue32899"
Title="Issue32899">
<Shell.TitleView>
<ImageButton Source="dotnet_bot.png"
HeightRequest="25"
WidthRequest="25"
AutomationId="TitleImageButton"/>
</Shell.TitleView>

<ShellContent>
<ContentPage>
<VerticalStackLayout Padding="20"
Spacing="10">
<Label Text="The dotnet bot image should be visible in the title bar above."/>
</VerticalStackLayout>
</ContentPage>
</ShellContent>
</Shell>
35 changes: 35 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue32899.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 32899, "Dotnet bot image is not showing up when using iOS 26 and macOS 26.1", PlatformAffected.iOS | PlatformAffected.macOS)]
public partial class Issue32899 : Shell
{
public Issue32899()
{
InitializeComponent();
Routing.RegisterRoute(nameof(Issue32899Subpage), typeof(Issue32899Subpage));
GoToAsync(nameof(Issue32899Subpage));
}

class Issue32899Subpage : ContentPage
{
public Issue32899Subpage()
{
Title = "Issue 32899 Subpage";
Content = new VerticalStackLayout
{
Padding = 20,
Spacing = 10,
Children =
{
new Label
{
Text = "The dotnet bot image should be visible in the title bar above.",
AutomationId = "InstructionLabel"
}
}
};
}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue32899 : _IssuesUITest
{
public Issue32899(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Dotnet bot image is not showing up when using iOS 26 and macOS 26.1";

[Test]
[Category(UITestCategories.Shell)]
public void TitleViewImageShouldBeVisible()
{
// Wait for the page to load
App.WaitForElement("InstructionLabel");

// Verify the ImageButton in TitleView is present
// The image itself should be rendered and visible
App.WaitForElement("TitleImageButton");
}
}
Loading