Skip to content

[iOS 26] Fix NavigationPage.TitleView not resizing on device rotation#46

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/review-pull-request-32815-again
Draft

[iOS 26] Fix NavigationPage.TitleView not resizing on device rotation#46
Copilot wants to merge 3 commits intomainfrom
copilot/review-pull-request-32815-again

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 23, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

On iOS 26+ and MacCatalyst 26+, NavigationPage.TitleView fails to resize when device orientation changes. The title view remains at its original width instead of expanding/contracting to fill the navigation bar.

Root cause: iOS 26+ changed autoresizing behavior for navigation bar title views. The autoresizing mask alone is insufficient - explicit frame updates are required during trait collection changes.

Fix: Override TraitCollectionDidChange in the navigation controller wrapper to detect size class transitions and explicitly update the title view frame to match the navigation bar dimensions.

public override void TraitCollectionDidChange(UITraitCollection previousTraitCollection)
{
    base.TraitCollectionDidChange(previousTraitCollection);
    
    // Check if orientation changed (size class transition)
    if (previousTraitCollection?.VerticalSizeClass != TraitCollection.VerticalSizeClass ||
        previousTraitCollection?.HorizontalSizeClass != TraitCollection.HorizontalSizeClass)
    {
        if (OperatingSystem.IsIOSVersionAtLeast(26) || OperatingSystem.IsMacCatalystVersionAtLeast(26))
        {
            UpdateTitleViewFrameForOrientation();
        }
    }
}

void UpdateTitleViewFrameForOrientation()
{
    if (NavigationItem?.TitleView is not UIView titleView)
        return;
        
    var navigationBarFrame = navigationRenderer.NavigationBar.Frame;
    titleView.Frame = new RectangleF(0, 0, navigationBarFrame.Width, navigationBarFrame.Height);
    titleView.LayoutIfNeeded();
}

Test coverage: Added UI test verifying TitleView width changes correctly on rotation and returns to original dimensions.

Issues Fixed

Fixes dotnet#32722

Original prompt

please review dotnet#32815

Custom agent used: pr-reviewer
Specialized agent for conducting thorough, constructive code reviews of .NET MAUI pull requests


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Review changes in pull request 32815 [iOS 26] Fix NavigationPage.TitleView not resizing on device rotation Nov 23, 2025
Copilot AI requested a review from kubaflo November 23, 2025 23:40
@kubaflo
Copy link
Copy Markdown
Owner

kubaflo commented Nov 23, 2025

@copilot proceed please

Co-authored-by: kubaflo <42434498+kubaflo@users.noreply.github.com>
@kubaflo
Copy link
Copy Markdown
Owner

kubaflo commented Nov 23, 2025

@copilot yes it is correct. proceed

Copy link
Copy Markdown
Author

Copilot AI commented Nov 24, 2025

@copilot yes it is correct. proceed

Proceeding with code review. Since this is an iOS 26+ specific fix and testing environment is Linux-based, I'll provide a detailed code review and create a checkpoint for iOS testing.

@kubaflo
Copy link
Copy Markdown
Owner

kubaflo commented Nov 24, 2025

@copilot Everything works I've tested it, please proceed

Copy link
Copy Markdown
Author

Copilot AI commented Nov 24, 2025

@copilot Everything works I've tested it, please proceed

Perfect! Finalizing review based on your iOS 26+ testing confirmation.

Final Review Summary

PR dotnet#32815: NavigationPage.TitleView Rotation Fix - iOS 26+

✅ Code Review: APPROVED

  • Correctly implements TraitCollectionDidChange override in ParentingViewController
  • Proper platform targeting (iOS 26+ / MacCatalyst 26+ only)
  • Defensive null checks and weak reference validation
  • Follows existing code patterns in NavigationRenderer

✅ Testing: VERIFIED

✅ Test Coverage: COMPLETE

  • UI test Issue32722.cs validates rotation behavior
  • Tests width changes on landscape/portrait transitions
  • Proper test categorization (UITestCategories.Navigation)

Issues Found: NONE

Recommendation

✅ APPROVE - Ready to merge

The PR successfully fixes the NavigationPage.TitleView resizing issue on iOS 26+ by explicitly updating the title view frame during trait collection changes. Code quality is excellent, testing is complete, and the fix is appropriately scoped to affected platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NavigationPage.TitleView does not expand with host window in iPadOS 26+

2 participants