私はシンプルUITableView
で、実装してデータをロードしていますUITableViewSource
。同じページにラベルもあります。tableview から選択した行をラベルに表示したいと思います。これは私のMainViewController
です:
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
List<string> lstTableSource = new List<string> ();
for (int intCounter=0; intCounter<5; intCounter++)
{
lstTableSource.Add ("Row "+intCounter);
}
tblTest.Source = new TableSource (lstTableSource.ToArray());
}
public void Test(string strSelected)
{
lblTest.Text = strSelected;
}
これは私の行選択方法ですTableSource.cs
public override void RowSelected (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
MainViewControllerObj.Test (tableItems[indexPath.Row]);
}
行システムをタップすると、NullReferenceExceptionがスローされます
lblTest.Text = strSelected;
変数の値をstrSelected
コンソールに出力すると、プログラムは正常に動作します。