2

I have a simple custom multiline element whose linebreak mode i've set to wordwrap, and lines property i set to 7. My text seems to wrap just fine, but the cell height stays the same, so the text extends the bounds of the cell. I've tried increasing the frame of the cell and overriding GetHeight, but it doesn't seem to work in either case. Also, it doesn't seem my GetHeight is even been called.

Any one face something similar? Or any ideas on what the issue might be?

public class DisclaimerMultilineElement : MultilineElement
{
    public DisclaimerMultilineElement (string caption) : base(caption)
    {
    }

    public DisclaimerMultilineElement (string caption, string value) : base(caption, value)
    {
    }

    public DisclaimerMultilineElement (string caption, NSAction tapped) : base(caption, tapped)
    {
    }

    public override float GetHeight (UITableView tableView, NSIndexPath indexPath)
    {
        var ht = base.GetHeight (tableView, indexPath);
        //return base.GetHeight (tableView, indexPath);
        return 400.0f;
    }

    public override UITableViewCell GetCell (MonoTouch.UIKit.UITableView tv)
    {
        UITableViewCell cell = base.GetCell (tv);
        var frame = cell.Frame;
        frame.Height = 300f;
        //cell.Frame = new System.Drawing.RectangleF(frame.X, frame.Y, frame.Width, frame.Height);
        cell.BackgroundColor = UIColor.Clear;
        cell.TextLabel.Font = UIFont.BoldSystemFontOfSize (12);
        cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap;
        cell.TextLabel.Lines = 7;
        cell.TextLabel.TextAlignment = UITextAlignment.Left;
        cell.TextLabel.Text = Value;
        return cell;
    }
}
DeleO
  • 108
  • 2
  • 8

2 Answers2

7

Make sure that UnevenRows is set to true in your Root element.

olexa.le
  • 1,697
  • 10
  • 14
2

You need to override GetHeightForRow in your UITableViewSource and return the appropriate height.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443