0

I have been following this guide: Resizing UITableView to fit content in order for the UiTableView to adjust its height after its content.

In the ViewDidLoad() method, I am filling my uiTable so it has 3 rows. So the content height should not be 0.

Do you have any ideas of what could be wrong?

This is my class:

public partial class ContentSizedTableView : UITableView
{
    public ContentSizedTableView(IntPtr handle) : base(handle)
    {
    }   

    public override CGSize ContentSize { get => base.ContentSize; set => InvalidateIntrinsicContentSize(); }

    public override CGSize IntrinsicContentSize
    {
        get
        {
            LayoutIfNeeded();
            return new CGSize(NoIntrinsicMetric, ContentSize.Height);
        }
    }
}
Malin
  • 97
  • 1
  • 8
  • you can refer to this officail document about auto-size:https://learn.microsoft.com/en-us/xamarin/ios/user-interface/controls/tables/autosizing-row-height – Adrain May 19 '22 at 07:32
  • Hi thanks, Maybe it was unclear but it is the UITableView not the rows that I want to be automatically sized. I have a UiTableview inside a scrollview and I want the table height to be equal to the height of the content @AdrainZhu-MSFT – Malin May 19 '22 at 07:46

0 Answers0