Issue
So using Visual Studio, C# and Xamarin and I have this I have a UITableViewController which lists a selection of records and when the user clicks on one of these I want them to see a UIViewController page with the full record details displayed.
When a record is select this function is correctly invoked in RowSelected, the full code is below.
However I am seeing 2 errors:
PartsViewController PartsView= this.storyboard.InstantiateViewController("PartsViewController") as PartsViewController;
Shows this error for storyboard:
this.PresentViewController(PartsView, true, null);
Shows this error for PresentViewController
This is my first IOS App so can anyone show me the error of my ways please.
Code:
public partial class PartsListController : UITableViewController
{
public List<String> Partss { get; set; }
public List<String> Ndx { get; set; }
static readonly NSString PartsListCellId = new NSString("PartsListCell");
public PartsListController (IntPtr handle) : base (handle)
{
TableView.RegisterClassForCellReuse(typeof(UITableViewCell), PartsListCellId);
TableView.Source = new PartsDataSource(this);
Partss = new List<string>();
Ndx = new List<String>();
}
class PartsDataSource : UITableViewSource
{
PartsListController controller;
public PartsDataSource(PartsListController controller)
{
this.controller = controller;
}
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
PartsViewController PartsView= this.storyboard.InstantiateViewController("PartsViewController") as PartsViewController;
string selection = controller.Partss[indexPath.Row];
string pos = controller.Ndx[indexPath.Row];
this.PresentViewController(PartsView, true, null);
}
public override nint RowsInSection(UITableView tableView, nint section)
{
return controller.Partss.Count;
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
var cell = tableView.DequeueReusableCell(PartsListController.PartsListCellId);
var row = indexPath.Row;
cell.TextLabel.Text = controller.Partss[row];
return cell;
}
}
}
}
Solution
Sorted Here we go
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
PartsViewController PartsView= controller.storyboard.InstantiateViewController("PartsViewController") as PartsViewController;
string selection = controller.Partss[indexPath.Row];
string pos = controller.Ndx[indexPath.Row];
controller.NavigationController.PushViewController(RecipeView, true);
}
Answered By - Kev
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.