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
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<string>(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.
Had the same issue, I just forgot to set the delegate in viewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
TableView.DataSource = new YourViewControllerTableDataSource();
TableView.Delegate = new YourViewControllerTableDelegate();
}