All samples that I encountered so far for using TableView were using UITableViewController. But I want use it in UIViewController. I am placing a Label at the top of the view and a TableView below it.
I am able to display the data in rows as needed.
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
selectedDate = Convert.ToDateTime (Application.selectedDateTime.ToShortDateString ());
lblCurrentDateValue.Text = "Date currently set to: " + selectedDate.ToShortDateString ();
// Create option list for date selection
DateTime now = DateTime.Today;
arrayOptionCells = new DateSelectionOptionCell[]
{
new DateSelectionOptionCell ("Yesterday", FormattedDateString (2, now.AddDays (-1)), null),
new DateSelectionOptionCell ("Today", FormattedDateString (2, now), null),
new DateSelectionOptionCell ("Tomorrow", FormattedDateString (2, now.AddDays (1)), null),
new DateSelectionOptionCell ("Day After", FormattedDateString (2, now.AddDays (2)), null),
new DateSelectionOptionCell ("n - Days after n =>", FormattedDateString (2, now.AddDays (7)), TFDaysAfter()),
new DateSelectionOptionCell ("Select Date Picker", FormattedDateString (2, now), null)
};
tblvDateSelection.Source = new DataSource(this);
tblvDateSelection.Delegate = new DateSelectionTableDelegate();
tblvDateSelection.ReloadData ();
}
In the above code the tblvDateSelection is the TableView. But the DataSource.RowSelected(…) is not firing on touching a row / section. I compared the class DataSource code with those working examples but using UITableViewController and not UIViewController.
What could be the reason for RowSelected not being fired?
ThanQ…
The problem seems to be that you’re setting both the UITableViewSource AND UITableViewDelegate, the UITableViewSource is actually a helper method that sets both the UITableViewDataSource AND UITableViewDelegate for you, if you do not set the UITableViewDelegate, then this should work for you.