diff options
author | Shawn Castrianni <shawn@spcware.com> | 2016-05-11 05:07:23 -0500 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-05-11 11:07:23 +0100 |
commit | 7ae7dbaa9695fac8fc0d818a808602d58ea0ce47 (patch) | |
tree | 4f8d0223c3ba2d0aedd8157da6025c114957fc48 /Xamarin.Forms.Platform.iOS | |
parent | 2c62350cde629cb972e21dd9cd88095cec40a82f (diff) | |
download | xamarin-forms-7ae7dbaa9695fac8fc0d818a808602d58ea0ce47.tar.gz xamarin-forms-7ae7dbaa9695fac8fc0d818a808602d58ea0ce47.tar.bz2 xamarin-forms-7ae7dbaa9695fac8fc0d818a808602d58ea0ce47.zip |
Fix Bug 39486 (#153)
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
3 files changed, 32 insertions, 16 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs index 2151d446..80fcf53f 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs @@ -41,7 +41,7 @@ namespace Xamarin.Forms.Platform.iOS public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { - return Control.GetSizeRequest(widthConstraint, heightConstraint, 44, 44); + return Control.GetSizeRequest(widthConstraint, heightConstraint, DefaultRowHeight, DefaultRowHeight); } public override void LayoutSubviews() @@ -1116,4 +1116,4 @@ namespace Xamarin.Forms.Platform.iOS _refreshAdded = false; } } -}
\ No newline at end of file +} diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs index 0e9e15f4..dcb943bf 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs @@ -148,10 +148,14 @@ namespace Xamarin.Forms.Platform.iOS public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath) { - var h = View.Model.GetCell(indexPath.Section, indexPath.Row).Height; - if (h == -1) + var cell = View.Model.GetCell(indexPath.Section, indexPath.Row); + var h = cell.Height; + + if (View.RowHeight == -1 && h == -1 && cell is ViewCell && Forms.IsiOS8OrNewer) { + return UITableView.AutomaticDimension; + } else if (h == -1) return tableView.RowHeight; return (nfloat)h; } } -}
\ No newline at end of file +} diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs index a77b32cc..cdfc138f 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs @@ -14,13 +14,14 @@ namespace Xamarin.Forms.Platform.iOS { public class TableViewRenderer : ViewRenderer<TableView, UITableView> { + const int DefaultRowHeight = 44; KeyboardInsetTracker _insetTracker; UIView _originalBackgroundView; RectangleF _previousFrame; public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { - return Control.GetSizeRequest(widthConstraint, heightConstraint, 44, 44); + return Control.GetSizeRequest(widthConstraint, heightConstraint, DefaultRowHeight, DefaultRowHeight); } public override void LayoutSubviews() @@ -92,7 +93,7 @@ namespace Xamarin.Forms.Platform.iOS SetSource(); UpdateRowHeight(); - + UpdateEstimatedRowHeight(); UpdateBackgroundView(); } @@ -103,11 +104,11 @@ namespace Xamarin.Forms.Platform.iOS { base.OnElementPropertyChanged(sender, e); - if (e.PropertyName == "RowHeight") + if (e.PropertyName == TableView.RowHeightProperty.PropertyName) UpdateRowHeight(); - else if (e.PropertyName == "HasUnevenRows") + else if (e.PropertyName == TableView.HasUnevenRowsProperty.PropertyName) SetSource(); - else if (e.PropertyName == "BackgroundColor") + else if (e.PropertyName == TableView.BackgroundColorProperty.PropertyName) UpdateBackgroundView(); } @@ -139,12 +140,23 @@ namespace Xamarin.Forms.Platform.iOS void UpdateRowHeight() { - var height = Element.RowHeight; - - if (height <= 0) - height = 44; + var rowHeight = Element.RowHeight; + if (Element.HasUnevenRows && rowHeight == -1 && Forms.IsiOS7OrNewer) { + if (Forms.IsiOS8OrNewer) + Control.RowHeight = UITableView.AutomaticDimension; + } else + Control.RowHeight = rowHeight <= 0 ? DefaultRowHeight : rowHeight; + } - Control.RowHeight = height; + void UpdateEstimatedRowHeight() + { + var rowHeight = Element.RowHeight; + if (Element.HasUnevenRows && rowHeight == -1) { + Control.EstimatedRowHeight = DefaultRowHeight; + } else { + if (Forms.IsiOS7OrNewer) + Control.EstimatedRowHeight = 0; + } } } -}
\ No newline at end of file +} |