From: Samantha Houts Date: Sat, 11 May 2019 19:08:21 +0000 (-0700) Subject: [Bug] ListView HasUnevenRows was not working in iOS 10 (#6166) X-Git-Tag: accepted/tizen/5.5/unified/20200421.150457~378^2^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=71c62a521408ee4a15e700450d7d705bcc586e91;p=platform%2Fcore%2Fcsapi%2Fxsf.git [Bug] ListView HasUnevenRows was not working in iOS 10 (#6166) * Add repro for #5888 Co-Authored-By: melimion * [iOS] Fix HasUnevenRows for iOS11+ Co-Authored-By: melimion fixes #5888 --- diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5888.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5888.cs new file mode 100644 index 0000000..d76843c --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5888.cs @@ -0,0 +1,26 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 5888, "[Bug] ListView HasUnevenRows is not working in iOS 10", PlatformAffected.iOS)] + public class Issue5888 : TestContentPage + { + protected override void Init() + { + + var stack2 = new StackLayout + { + Children = { new Label { Text = "Hi" }, new Label { Text = "Bye" }, new Label { Text = "Open" } } + }; + var listview = new ListView + { + HasUnevenRows = true, + ItemTemplate = new DataTemplate(() => new ViewCell { View = stack2 }), + ItemsSource = new string[] { "mono", "monodroid" } + }; + Content = new StackLayout { Children = { listview } }; + } + } +} \ 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 03d7d2d..d996581 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 @@ -892,6 +892,7 @@ Issue4356.xaml + diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs index bbe0a77..613af35 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs @@ -711,7 +711,7 @@ namespace Xamarin.Forms.Platform.iOS if (_tableViewController != null) _tableViewController.UpdateRefreshControlColor(color == Color.Default ? null : color.ToUIColor()); - } + } void UpdateVerticalScrollBarVisibility() { @@ -817,11 +817,11 @@ namespace Xamarin.Forms.Platform.iOS protected override void UpdateEstimatedRowHeight(UITableView tableView) { - var estimatedRowheight = GetEstimatedRowHeight(tableView); + var estimatedRowHeight = GetEstimatedRowHeight(tableView); //if we are providing 0 we are disabling EstimatedRowHeight, //this works fine on newer versions, but iOS10 it will cause a crash so we leave the default value - if (estimatedRowheight == 0 && Forms.IsiOS11OrNewer) - tableView.EstimatedRowHeight = estimatedRowheight; + if (estimatedRowHeight > 0 || (estimatedRowHeight == 0 && Forms.IsiOS11OrNewer)) + tableView.EstimatedRowHeight = estimatedRowHeight; } internal Cell GetPrototypicalCell(NSIndexPath indexPath) @@ -1247,7 +1247,7 @@ namespace Xamarin.Forms.Platform.iOS { UpdateShortNameListener(); - if(List.OnThisPlatform().RowAnimationsEnabled()) + if (List.OnThisPlatform().RowAnimationsEnabled()) _uiTableView.ReloadData(); else PerformWithoutAnimation(() => { _uiTableView.ReloadData(); }); @@ -1551,7 +1551,8 @@ namespace Xamarin.Forms.Platform.iOS public override void ViewWillAppear(bool animated) { (TableView?.Source as ListViewRenderer.ListViewDataSource)?.Cleanup(); - if (!_list.IsRefreshing || !_refresh.Refreshing) return; + if (!_list.IsRefreshing || !_refresh.Refreshing) + return; // Restart the refreshing to get the animation to trigger UpdateIsRefreshing(false);