我想這樣做,當我按下我的UITableView行時,它會發送一些數據到另一個UIViewController並使一個seque。RowSelected - NullReferenceException
然而測試出來的時候,它給了我:
System.NullReferenceException已經拋出的對象引用未設置 爲對象
的錯誤似乎在這裏展示的實例:
viewController.NavigationController.PushViewController (detail, true);
這裏是我的 「RowSelected」
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
Console.WriteLine ("Row: " + tableItems [indexPath.Row].Heading);
//new UIAlertView("Row Selected", tableItems[indexPath.Row].Heading, null, "OK", null).Show();
tableView.DeselectRow (indexPath, true);
// Specially for Storyboard !!
var detail = viewController.Storyboard.InstantiateViewController("detail") as HolsteinItemViewController;
detail.Title = tableItems[indexPath.Row].Heading;
detail.LoadUrl (tableItems[indexPath.Row].SubHeading);
viewController.NavigationController.PushViewController (detail, true);
}
捕獲到異常:
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);
Main.cs第16行
UIApplication.Main (args, null, "AppDelegate");
是否tableItems [indexPath.Row] .Heading和Subheading不爲null? – user1646737
兩者都應該設置,因爲它們都顯示在單元格 –
是否有一些其他屬性的細節是預期的,但沒有定義? – user1646737