UITableViewで行を押すと、別のUIViewControllerにデータが送信され、シークが作成されるようにしようとしています。
ただし、テストすると、次のようになります。
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");