diff --git a/src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs b/src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs index 8d478c7265a1..22af9333c131 100644 --- a/src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs +++ b/src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs @@ -528,11 +528,11 @@ void TearDownEmptyView() _emptyViewFormsElement = null; } - void LayoutEmptyView() + virtual internal CGRect LayoutEmptyView() { if (!_initialized || _emptyUIView == null || _emptyUIView.Superview == null) { - return; + return CGRect.Empty; } var frame = DetermineEmptyViewFrame(); @@ -541,6 +541,8 @@ void LayoutEmptyView() if (_emptyViewFormsElement != null && ((IElementController)ItemsView).LogicalChildren.IndexOf(_emptyViewFormsElement) != -1) _emptyViewFormsElement.Layout(frame.ToRectangle()); + + return frame; } internal protected virtual void UpdateVisibility() diff --git a/src/Controls/src/Core/Handlers/Items2/iOS/StructuredItemsViewController2.cs b/src/Controls/src/Core/Handlers/Items2/iOS/StructuredItemsViewController2.cs index 32df41d56e1c..d5dd2aea316f 100644 --- a/src/Controls/src/Core/Handlers/Items2/iOS/StructuredItemsViewController2.cs +++ b/src/Controls/src/Core/Handlers/Items2/iOS/StructuredItemsViewController2.cs @@ -161,6 +161,22 @@ string DetermineViewReuseId(DataTemplate template, object item) : VerticalSupplementaryView2.ReuseId; } + internal override CGRect LayoutEmptyView() + { + var emptyViewFrame = base.LayoutEmptyView(); + var footerView = CollectionView.ViewWithTag(FooterTag); + + if (footerView is not null) + { + if (emptyViewFrame.Height > 0) + footerView.Frame = new CGRect(footerView.Frame.X, emptyViewFrame.Bottom, footerView.Frame.Width, footerView.Frame.Height); + else + footerView.Frame = new CGRect(footerView.Frame.X, CollectionView.ContentSize.Height - footerView.Frame.Height, footerView.Frame.Width, footerView.Frame.Height); + } + + return emptyViewFrame; + } + protected override CGRect DetermineEmptyViewFrame() { nfloat headerHeight = 0; @@ -175,7 +191,7 @@ protected override CGRect DetermineEmptyViewFrame() if (footerView != null) footerHeight = footerView.Frame.Height; - return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y, CollectionView.Frame.Width, + return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y + headerHeight, CollectionView.Frame.Width, Math.Abs(CollectionView.Frame.Height - (headerHeight + footerHeight))); } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25606.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue25606.xaml new file mode 100644 index 000000000000..7a9d9b5592cd --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25606.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25606.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue25606.xaml.cs new file mode 100644 index 000000000000..92f4c1307da3 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25606.xaml.cs @@ -0,0 +1,11 @@ +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, "25606", "Empty View Overlapping Header in CollectionView with CollectionViewHandler2", PlatformAffected.iOS)] + public partial class Issue25606 : ContentPage + { + public Issue25606() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25606.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25606.cs new file mode 100644 index 000000000000..e5bbac48673a --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25606.cs @@ -0,0 +1,22 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues +{ + public class Issue25606 : _IssuesUITest + { + public Issue25606(TestDevice testDevice) : base(testDevice) + { + } + + public override string Issue => "Empty View Overlapping Header in CollectionView with CollectionViewHandler2"; + + [Test] + [Category(UITestCategories.CollectionView)] + public void HeaderShouldNotBeCoveredByEmptyView() + { + App.WaitForElement("Header"); + } + } +} \ No newline at end of file