title: Multiple Views on one Container View
body: <p>I currently have some coding in place that I followed from a tutorial to allow multiple view controllers inside one container view and the use of custom segues with identifiers to present a new view controller when a row in a table is selected.</p>
  
  <p>I am coding in xamarin.ios</p>
  
  <p>Now I have the row selected part working and it activates the correct line in my ContainerViewController. However, it then throws an error when the PerformSegue is activated as it says that</p>
  
  <blockquote>
    <p>Objective-C exception thrown. name: NSInvalidArgumentException Reason: Reciever () has no segue with identifier 'test1'</p>
  </blockquote>
  
  <p>I have the segue with the id test1 so the id is correct but stills throws that error.</p>
  
  <p>This is the tutorial I followed: <a href="https://kodesnippets.wordpress.com/2015/08/11/container-view-in-ios/" rel="nofollow noreferrer">https://kodesnippets.wordpress.com/2015/08/11/container-view-in-ios/</a></p>
  
  <p>This is the code for ContainerViewController:</p>
  
  <pre><code>namespace PMApp
  {
      public partial class ContainerViewController : UIViewController
      {
          public ContainerViewController(IntPtr handle) : base(handle) { }
          public ContainerViewController() : base("ContainerViewController", null){}
  
          UIViewController vc;
          string segueIdentifier;
          UIViewController lastViewController;
  
          public void segueIdentifireRecievedFromParent(int selectedRow)
          {
              ContainerViewController containerController = new ContainerViewController();
  
              if (selectedRow == 0)
              {
                  segueIdentifier = "test1";
                  PerformSegue(segueIdentifier, null);
  
              }
              else if (selectedRow == 1)
              {
                  segueIdentifier = "test2";
                  PerformSegue(segueIdentifier, null);
              }
          }
  
          public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
          {
              base.PrepareForSegue(segue, sender);
  
              if (segue.Identifier == segueIdentifier)
              {
                  if (lastViewController != null)
                  {
                      lastViewController.View.RemoveFromSuperview();
                  }
  
                  vc = segue.DestinationViewController as UIViewController;
                  AddChildViewController(vc);
                  View.AddSubview(vc.View);
                  vc.DidMoveToParentViewController(this);
                  lastViewController = vc;
              }
          }    
      }
  }
  </code></pre>
  
  <p>This is the class which handles my table and row selection:</p>
  
  <pre><code>namespace PMApp.Classes
  {
      public class TableSource : UITableViewSource
      {
          List&lt;string&gt; TableItems;
          string CellIdentifier = "AreaCell";
  
          public TableSource(List&lt;string&gt; items)
          {
              TableItems = items;
          }
  
          public override nint RowsInSection(UITableView tableview, nint section)
          {
              return TableItems.Count;
          }
  
          public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
          {
              UITableViewCell cell = tableView.DequeueReusableCell(CellIdentifier);
              string item = TableItems[indexPath.Row];
  
              //---- if there are no cells to reuse, create a new one
              if (cell == null)
              { cell = new UITableViewCell(UITableViewCellStyle.Default, CellIdentifier); }
  
              cell.TextLabel.Text = item;
  
              return cell;
          }
  
          public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
          {
              ContainerViewController containerController = new ContainerViewController();
  
              containerController.segueIdentifireRecievedFromParent(indexPath.Row);
              //MainViewController.PresentContainerView(indexPath.Row);  
              tableView.DeselectRow(indexPath, true);
          }
  
          private void newAlertView()
          {
              var alertController = UIAlertController.Create("Title", "Message", UIAlertControllerStyle.Alert);
              alertController.AddAction(UIAlertAction.Create("back", UIAlertActionStyle.Default, null));
  
          }
      }
  }
  </code></pre>
  
  <p>Hopefully somebody can help, been searching everywhere on the solution but just cant find nothing to solve the problem. </p>