简体   繁体   中英

Xamarin iOS RowSelected Event navigate to 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

My code:

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<Item> Items, UIViewController viewController) { _Items= Items; parentController = viewController; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM