diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7758.xaml b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7758.xaml new file mode 100644 index 000000000..3546c7b5b --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7758.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7758.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7758.xaml.cs new file mode 100644 index 000000000..2794be78a --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7758.xaml.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 7758, "[iOS] EmptyView is not rendered in screen center", PlatformAffected.iOS)] + public partial class Issue7758 : TestContentPage + { + public Issue7758() + { +#if APP + Device.SetFlags(new List { CollectionView.CollectionViewExperimental }); + + InitializeComponent(); +#endif + } + + protected override void Init() + { + + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 9b1811478..e11cdf5f7 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -55,6 +55,9 @@ Code + + Code + Code @@ -1418,6 +1421,9 @@ Issue7593.xaml + + Issue7758.xaml + @@ -1479,4 +1485,10 @@ MSBuild:Compile - + + + Designer + MSBuild:Compile + + + \ No newline at end of file diff --git a/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewController.cs b/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewController.cs index f1c9e3d0b..206635946 100644 --- a/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewController.cs +++ b/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewController.cs @@ -140,8 +140,13 @@ namespace Xamarin.Forms.Platform.iOS if (!_initialConstraintsSet) { ItemsViewLayout.ConstrainTo(CollectionView.Bounds.Size); + UpdateEmptyView(); _initialConstraintsSet = true; } + else + { + ResizeEmptyView(); + } } protected virtual UICollectionViewDelegator CreateDelegator() @@ -267,6 +272,15 @@ namespace Xamarin.Forms.Platform.iOS UpdateEmptyViewVisibility(ItemsSource?.ItemCount == 0); } + void ResizeEmptyView() + { + if (_emptyUIView != null) + _emptyUIView.Frame = CollectionView.Frame; + + if (_emptyViewFormsElement != null) + _emptyViewFormsElement.Layout(CollectionView.Frame.ToRectangle()); + } + protected void UpdateSubview(object view, DataTemplate viewTemplate, ref UIView uiView, ref VisualElement formsElement) { uiView?.RemoveFromSuperview(); diff --git a/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewRenderer.cs b/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewRenderer.cs index 630351e52..837b1d4b6 100644 --- a/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewRenderer.cs @@ -97,7 +97,6 @@ namespace Xamarin.Forms.Platform.iOS SetNativeControl(ItemsViewController.View); ItemsViewController.CollectionView.BackgroundColor = UIColor.Clear; - ItemsViewController.UpdateEmptyView(); UpdateHorizontalScrollBarVisibility(); UpdateVerticalScrollBarVisibility();