如何在rowselect委托方法的xamarin.ios中导航到viewcontroller

时间:2014-09-08 04:38:45

标签: xamarin.ios

我正在从Table View导航到View Controller,当我点击行时,我得到例外System.NullReferenceException has been thrown Object reference not set to an instance of an object

这是代码:

    UITableViewController _contact;

    public Contactlist(UITableViewController contact)
    {

      _contact=contact;

    }

public override void Row Selected (UITableView tableView, NSIndexPath indexPath)
{

   // Error System.NullReferenceException
   _contact.NavigationController.PushViewController(new incomingscreen(),true);

}

请帮助

1 个答案:

答案 0 :(得分:0)

除非ViewController包含在NavigationController中,否则ViewController的NavigationController属性将为null。

window.RootViewController = new UINavigationController(new MyTableViewController());