我到目前爲止使用TableView時遇到的所有示例都使用UITableViewController。但我想在UIViewController中使用它。我在視圖頂部放置了一個Label,並在其下面放置了一個TableView。MonoTouch:當在TableView中選擇一行時,DataSource.RowSelected()不會觸發
我可以根據需要在行中顯示數據。
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();
}
在上面的代碼中,tblvDateSelection是TableView。但是DataSource.RowSelected(...)在觸摸一行/一節時不會觸發。我將類DataSource代碼與那些工作示例進行了比較,但使用UITableViewController而不是UIViewController。
RowSelected沒有被解僱的原因是什麼?
ThanQ ...
謝謝@chrisntr。有用。 – ESM 2012-02-28 23:04:37