Monotouch:在TableView中选择行时,不触发DataSource.RowSelected()

时间:2012-02-24 04:01:26

标签: ios xamarin.ios tableview

到目前为止,我使用TableView遇到的所有示例都使用了UITableViewController。但我想在UIViewController中使用它。我在视图的顶部放置一个Label,在它下面放置一个TableView。

我可以根据需要在行中显示数据。

        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

2 个答案:

答案 0 :(得分:2)

问题似乎是你要设置 UITableViewSource UITableViewDelegate UITableViewSource 实际上是一个帮助它设置两者的辅助方法你可以使用 UITableViewDataSource UITableViewDelegate ,如果你没有设置UITableViewDelegate,那么这应该适合你。

答案 1 :(得分:0)

我有一个类似的问题......我的似乎是调试器没有破坏我在RowSelect中的断点。所以它似乎没有被召唤!

他们修复了最新调试器中“覆盖虚拟方法”的问题。