I'm having trouble calling a second ViewController inside the RowSelected method in a class containing the UITableViewSource interface, making the same call by instantiating the ViewControlller causes a " Object reference not set to an instance of an object ", but I'm banging my head to solve this problem, could someone tell me what's going on?
using System;
using System.Collections.Generic;
using ClickDeliveryMobile.IOS.Views;
using Foundation;
using UIKit;
namespace ClickDeliveryMobile.IOS.DataSources
{
public class CategoriaTableViewSource: UITableViewSource
{
private List<string> ListCategorias;
public CategoriaTableViewSource(List<string> ListCategorias)
{
this.ListCategorias = ListCategorias;
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
var cell = new UITableViewCell(UITableViewCellStyle.Default, "");
cell.TextLabel.Text = ListCategorias[indexPath.Row];
return cell;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
return ListCategorias.Count;
}
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
var selecionaCat = ListCategorias[indexPath.Row];
CategoriaViewController categoria = new CategoriaViewController();
categoria.NavigationController.PushViewController(new SobreViewController(), true);
Console.WriteLine(selecionaCat);
}
}
}