Hi,
I'm trying to get variable row heights to work in table views. I found this excellent post on StackOverflow and have been trying to translate smileyborg's solution into C#. Try as I might, this logic for measuring cell size is always returning zero:
public override float GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
if (this.offscreenCell == null)
{
this.offscreenCell = new ItemCell();
}
var cell = this.offscreenCell;
cell.UpdateFonts();
var item = this.model.Items[indexPath.Row];
cell.Title = item.Title;
cell.Body = item.Body;
cell.SetNeedsUpdateConstraints();
cell.UpdateConstraintsIfNeeded();
cell.Bounds = new RectangleF(0, 0, this.TableView.Bounds.Width, this.TableView.Bounds.Height);
cell.SetNeedsLayout();
cell.LayoutIfNeeded();
var height = cell.ContentView.SystemLayoutSizeFittingSize(UIView.UILayoutFittingCompressedSize).Height;
height += 1;
return height;
}
Can anyone tell me what I'm doing wrong? I've attached my full project showing what I've done.
Thanks