Fix Bug 39486 (#153)
This commit is contained in:
Родитель
2c62350cde
Коммит
7ae7dbaa96
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
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;
|
||||
}
|
||||
|
||||
if (height <= 0)
|
||||
height = 44;
|
||||
|
||||
Control.RowHeight = height;
|
||||
void UpdateEstimatedRowHeight()
|
||||
{
|
||||
var rowHeight = Element.RowHeight;
|
||||
if (Element.HasUnevenRows && rowHeight == -1) {
|
||||
Control.EstimatedRowHeight = DefaultRowHeight;
|
||||
} else {
|
||||
if (Forms.IsiOS7OrNewer)
|
||||
Control.EstimatedRowHeight = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче