Override DialogViewController methods never called?

This is my first question, I apologize if it is not the best.

I am new to Xamarin and iOS. I have a custom implementation of DialogViewController, so I can override some methods in the UITableViewController. For the sake of the question, this is a very simple implementation.

public class CustomDialogViewController : DialogViewController
    {
        public CustomDialogViewController(RootElement root)
            : base (root)
        { }

        public override NSIndexPath WillSelectRow(UITableView tableView, NSIndexPath indexPath)
        {
            return base.WillSelectRow(tableView, indexPath);
        }

        public override NSIndexPath WillDeselectRow(UITableView tableView, NSIndexPath indexPath)
        {
            return base.WillDeselectRow(tableView, indexPath);
        }

        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            base.RowSelected(tableView, indexPath);
        }
    }

I create my instance as follows:

var rootElement = new RootElement("Main");
_mainSection = new Section();
rootElement.Add(_mainSection);
dvcProductGroupList = new CustomDialogViewController(rootElement);
dvcProductGroupList.Style = UITableViewStyle.Plain;
dvcProductGroupList.TableView.Frame = new RectangleF(...);
dvcProductGroupList.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
dvcProductGroupList.OnSelection += dvcProductGroupList_OnSelection;

DialogViewController. , . , , 4 . MonoTouch Dialog. , , , , , , , .

.

+3
2

, , , - , , , , , - ​​ . JonathanBird Xamarin.

. DialogViewController UITableViewSource UITableView. , UITableViewSource UITableViewController, UITableViewController . DialogViewController UITableViewController, .

DialogViewController UITableViewSource DialogViewController.Source. , , DialogViewController.Source .

, DialogViewController.Source, DialogViewController, . , CreateSizeSource() CustomDialogViewController.

DialogViewController CreateSizeSouce().

public virtual DialogViewController.Source CreateSizingSource (bool unevenRows)
{
    return (!unevenRows) ? new DialogViewController.Source (this) : new DialogViewController.SizingSource (this);
}

unevenRows, .

, CustomDialogViewController :

public override Source CreateSizingSource (bool unevenRows)
{
    return new CustomSource(this);
}

CustomSource - DialogViewController.Source, , .

, , RowSelected.

public class CustomDialogViewController : DialogViewController
{
    public CustomDialogViewController (RootElement root) : base (root) {}

    public override Source CreateSizingSource (bool unevenRows)
    {
        return new CustomSource(this);
    }

    private class CustomSource : DialogViewController.Source
    {
        public CustomSource (CustomDialogViewController controller) : base (controller)
        {}

        public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
        {
            // You handle row selected here
            base.RowSelected (tableView, indexPath);
        }
    }
}
+3

, UITableViewController ObjC UITableViewDataSource. :

this.TableView.WeakDataSource = this;

.

MT.Dialog, UITableView. /. .

0

All Articles