TableView does not call GetHeightForRow

2019-08-07 05:04发布

问题:

I have a class which inherits from UITableViewSource and overrides GetHeightForRow:

public override float GetHeightForRow(UITableView tableView, NSIndexPath indexPath)

However, at some point in time the OS stopped calling this method, so all my cells have the same height now. The rest of the table and table source is working fine. This is very strange, and I have tried all sorts of things, but it just does not call the method. The other overridden methods of the table source are called normally.

Is there some sort of a setting which makes the UITableView stop calling GetHeightForRow?

回答1:

Could you be setting both a Delegate (or WeakDelegate) of type UITableViewDelegate and the Source (of type UITableViewSource) property ?

They both expose GetHeightForRow and they will conflict if both are used on the same UITableView.



回答2:

Add the below line in ViewWillAppear method. This works out.

        TableView.Source = new ItemsSource ();