diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs index ec0d89980a9f..c25ec4cbd898 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs @@ -271,6 +271,11 @@ protected virtual void OnRendererSet() ViewController.AutomaticallyAdjustsScrollViewInsets = false; } } + + internal void UpdateTitleViewInternal() + { + UpdateTitleView(); + } protected virtual void UpdateTitleView() { @@ -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 && @@ -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) @@ -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 diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs index ac0f55a9985e..d4e219bf0891 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs @@ -829,6 +829,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(); + } } } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue32899.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue32899.xaml new file mode 100644 index 000000000000..50607989681f --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue32899.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue32899.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue32899.xaml.cs new file mode 100644 index 000000000000..13fbe69089e3 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue32899.xaml.cs @@ -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" + } + } + }; + } + } +} + + diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32899.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32899.cs new file mode 100644 index 000000000000..04bc5927dfca --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32899.cs @@ -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"); + } +}