Repository navigation
Fix TitleView not showing in iOS 26 - #32793
StephaneDelcroix wants to merge 1 commit into
Conversation
- Modified TitleViewContainer to use autoresizing masks for iOS 26+ and MacCatalyst 26+ - Added constructor to set frame from navigation bar dimensions - Updated UpdateTitleView to use new constructor for iOS 26+ - Added test case Issue32777 with UI test to verify the fix This addresses the issue where custom TitleViews were not displaying correctly in iOS 26 due to changes in how UINavigationItem.TitleView handles autolayout constraints. The fix switches to using autoresizing masks for iOS 26+, which resolves the display issues while maintaining backward compatibility. Fixes #32777
0c66cfc to
61f2cc0
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR aims to fix an issue where custom TitleViews in Shell navigation were not displaying correctly in iOS 26 and MacCatalyst 26. However, the PR contains several critical issues and unrelated changes that need to be addressed.
Key Changes
- Modified TitleViewContainer to use autoresizing masks instead of autolayout constraints for iOS 26+
- Added new test case (Issue32777) with XAML, code-behind, and UI tests
- Fixed a bug in source generator where TargetNullValue binding property flag was incorrectly checked
- Enhanced source generator test infrastructure with compilation error checking
- Added verbatim string literals (@"") for file paths in source generators
- Added new XAML unit testing guidelines documentation
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs | Core fix switching to autoresizing masks for iOS 26+ (but version number is incorrect) |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32777.cs | UI test implementation (missing TitleView visibility verification) |
| src/Controls/tests/TestCases.HostApp/Issues/Issue32777.xaml | Test page XAML with TitleView and content |
| src/Controls/tests/TestCases.HostApp/Issues/Issue32777.xaml.cs | Test page code-behind (incorrect PlatformAffected value) |
| src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs | Enhanced test infrastructure with compilation validation |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/*.cs | Updated tests to use new compilation checking parameter |
| src/Controls/src/SourceGen/CompiledBindingMarkup.cs | Fixed TargetNullValue flag bug (unrelated to TitleView, not documented) |
| src/Controls/src/SourceGen/*.cs | Added verbatim string literals for file paths |
| .github/instructions/xaml-unittests.instructions.md | New XAML unit testing guidelines (unrelated, not documented) |
| { | ||
| var view = new TitleViewContainer(titleView, frame); | ||
| NavigationItem.TitleView = view; | ||
| } |
There was a problem hiding this comment.
Missing null check and potential crash
If ViewController?.NavigationController?.NavigationBar.Frame is null (returns null for CGRect?), the code inside this if block won't execute, and NavigationItem.TitleView won't be set at all. This could leave the TitleView in an inconsistent state.
Consider adding an else clause or logging when the frame is not available:
if (OperatingSystem.IsIOSVersionAtLeast(26) || OperatingSystem.IsMacCatalystVersionAtLeast(26))
{
if (ViewController?.NavigationController?.NavigationBar.Frame is CGRect frame)
{
var view = new TitleViewContainer(titleView, frame);
NavigationItem.TitleView = view;
}
else
{
// Fallback to default constructor if frame is not available
var view = new TitleViewContainer(titleView);
NavigationItem.TitleView = view;
}
}| } | |
| } | |
| else | |
| { | |
| // Fallback to default constructor if frame is not available | |
| var view = new TitleViewContainer(titleView); | |
| NavigationItem.TitleView = view; | |
| } |
| @@ -0,0 +1,10 @@ | |||
| namespace Maui.Controls.Sample.Issues; | |||
|
|
|||
| [Issue(IssueTracker.Github, 32777, "TitleView not showing in iOS 26", PlatformAffected.iOS)] | |||
There was a problem hiding this comment.
Issue attribute uses incorrect PlatformAffected value
The PlatformAffected parameter should be PlatformAffected.iOS | PlatformAffected.MacCatalyst (or PlatformAffected.All) since the PR description states this affects both iOS 26+ and MacCatalyst 26+.
Using only PlatformAffected.iOS is inconsistent with the actual platforms affected by this issue.
| [Issue(IssueTracker.Github, 32777, "TitleView not showing in iOS 26", PlatformAffected.iOS)] | |
| [Issue(IssueTracker.Github, 32777, "TitleView not showing in iOS 26", PlatformAffected.iOS | PlatformAffected.MacCatalyst)] |
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
Fixes #32777 - TitleView not showing in iOS 26
This PR addresses the issue where custom TitleViews in Shell navigation were not displaying correctly in iOS 26 and MacCatalyst 26 due to changes in how UINavigationItem.TitleView handles autolayout constraints.
Changes Made
Core Fix
Test Coverage
Technical Details
In iOS 26+, Apple changed how UINavigationItem.TitleView handles autolayout constraints. The fix switches to using autoresizing masks for iOS 26+, which resolves the display issues while maintaining backward compatibility.
Testing
✅ UI Test: Issue32777.TitleViewShouldBeVisibleAndNotCoverContent - PASSED
Platforms Affected
Backward Compatibility
Maintains full backward compatibility with iOS versions prior to 26.
Related Issues
Fixes #32777