C# RowSelected-NullReferenceException

C# RowSelected-NullReferenceException,c#,ios,xamarin.ios,xamarin,nullreferenceexception,C#,Ios,Xamarin.ios,Xamarin,Nullreferenceexception,当我按下UITableView上的一行时,它会将一些数据发送到另一个UIViewController并进行排序 但是,在测试时,它给了我: 已引发System.NullReferenceException对象引用未设置 指向对象的实例 错误似乎显示在这里: viewController.NavigationController.PushViewController (detail, true); 这是我的“RowSelected” 捕获异常: System.NullReferenceExcep

当我按下UITableView上的一行时,它会将一些数据发送到另一个UIViewController并进行排序

但是,在测试时,它给了我:

已引发System.NullReferenceException对象引用未设置 指向对象的实例

错误似乎显示在这里:

viewController.NavigationController.PushViewController (detail, true);
这是我的“RowSelected”

捕获异常:

System.NullReferenceException: Object reference not set to an instance of an object
  at Holstein.TableSource.RowSelected (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x0008e] in /Users/Emil/Projects/Holstein/Holstein/Code/TableSource.cs:41
  at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
  at Holstein.Application.Main (System.String[] args) [0x00008] in /Users/Emil/Projects/Holstein/Holstein/Main.cs:16
TableSource.cs第46行

viewController.NavigationController.PushViewController (detail, true);
UIApplication.Main (args, null, "AppDelegate");
Main.cs第16行

viewController.NavigationController.PushViewController (detail, true);
UIApplication.Main (args, null, "AppDelegate");

您的
viewController.NavigationController
属性为空。根据iOS
UIViewController
参考

如果接收器或其祖先之一是导航的子对象 控制器,此属性包含所属的导航控制器。 如果视图控制器未嵌入到 导航控制器


显然,该视图控制器不是
UINavigationController
堆栈的一部分。

都是tableItems[indexPath.Row]。Heading和Subheading不为null?都应该设置,当它们都显示在单元格中时,是否存在其他预期但未定义的详细属性?如果在尝试推送控制器时引发null引用异常,则“viewController”的NavigationController属性很可能为null。那个控制器真的被推到导航控制器上了吗?它当时是可见的,还是只是实例化的?您可以共享完整的堆栈跟踪吗?如何将其添加到堆栈中?方法是调用UINavigationController的PushViewController方法。请回答这个问题