GetHeightForHeader and GetViewForHeader not called

前端 未结 2 590
轮回少年
轮回少年 2021-01-13 22:35

I am working on a tableview which has two sections. And I would like to add a headerView in the second section header.

I have implemented the following code. It cal

2条回答
  •  不思量自难忘°
    2021-01-13 23:04

    I had the same problem just realised I was setting the delegate and the source like so:

    Table.Delegate = new TableDelegate(this); //remove this bit
    Table.Source = new TableSource(list, Table);
    

    I realised that I should be using only UITableViewSource and not setting both.

    UITableViewSource replaces the following two classes, which are still available in Xamarin.iOS but are not normally required:

    UITableViewDataSource – An Objective-C protocol that is modeled in Xamarin.iOS as an abstract class. Must be subclassed to provide a table with a view for each cell, as well as information about headers, footers and the number of rows and sections in the table.

    UITableViewDelegate – An Objective-C protocol that is modeled in Xamarin.iOS as a class. Handles selection, editing features and other optional table features.

    Xamarin docs

    I just moved my rowselected method into my TableSource and it now calls the TitleForHeader and GetViewForHeader methods (they are not mutually exclusive) and only set the source no delegate.

提交回复
热议问题