'Xamarin.iOS native - Resizing UITableView after Content. ContentHeight is always 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);
        }
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source