Xamarin iOS RowSelected 事件导航到 ViewController [英] Xamarin iOS RowSelected Event navigate to ViewController

查看:20
本文介绍了Xamarin iOS RowSelected 事件导航到 ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个tableview.我希望当我单击一行以捕获列表中的行信息并将它们传递到 DetailScreen UIViewController 时.我已经使用 xamarin Studio 创建了 iPhone 视图控制器,并且我使用的是 Xcode 的布局.我正在尝试以下代码,但出现错误System.NullReferenceException: Object reference not set to an instance of an object"我尝试了这个解决方案但没有成功:如何在 RowSelected 事件中导航到 Xamarin iOS 中的 ViewController

I have a tableview. I would like when i click on a row to capture row info on a list and pass them on DetailScreen UIViewController. I have create iPhone view controllers with xamarin studio and for the layout i am using Xcode. I am trying the follow code but i am taking error"System.NullReferenceException: Object reference not set to an instance of an object " I have tried this solution without success: How to navigate to ViewController in Xamarin iOS on RowSelected event

我的代码:

UIViewController parentController;
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
   var dtscreen = new DetailScreen (mylist);
   parentController.NavigationController.PushViewController(dtscreen,true);// Error System.NullReferenceException
   tableView.DeselectRow (indexPath, true);
   }        

推荐答案

请更改下一部分代码:

public TableSource (List Items, UIViewController viewController){_Items= 物品;父控制器 = 视图控制器;}

这篇关于Xamarin iOS RowSelected 事件导航到 ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆