Title: Switching to different UITableViewControllers with UISegementedControl
Tags: xamarin.ios;xamarin;uisegmentedcontrol
Question: I've an UINavigationViewController with an UISegmentedControl in the navigation bar. I want to achieve a simple switching to different ViewControllers when users push on the segmented control.
I've tried a lot and nothing works... Considered sources:
MonoTouch Instantiating a ViewController programmatically for ContainerView
https://stackoverflow.com/search?q=viewcontroller+intptr+handle
And a lot of google research...
The whole project is storyboard based! Any solutions which targets NIB's aren't useful.
Adding a ContainerControl to my UINavigationViewController. But in this case I can only embed one controller. Creating a Embedded-Segue programmatically was not possible. Even more instantiating a UITableViewController in code which is designed in IB results in an empty view. Because I've to change the c'tor from MyTableViewController(IntPtr handle) : base(handle) to an empty constructor.
Can someone publish a working example how to use a UISegmentedControl to switch between different ViewControllers? I appreciate all your help very much.

Here is the accepted answer: Working solution:
public override void ViewDidLoad ()
base.ViewDidLoad ();
CreateAndEmbed (TrDetailNavType.Info);
partial void segmentNavigationValueChanged (MonoTouch.UIKit.UISegmentedControl sender, MonoTouch.UIKit.UIEvent e)
CreateAndEmbed((TrDetailNavType)sender.SelectedSegment);
private void CreateAndEmbed(TrDetailNavType tab)
if (_currentViewController != null)
{
_currentViewController.View.RemoveFromSuperview ();
_currentViewController.RemoveFromParentViewController();
}
string id;
switch (tab)
{
case TrDetailNavType.Info:
id = "TagesRapportDetailInfoTableViewController";
break;
case TrDetailNavType.Lohn:
case TrDetailNavType.Material:
case TrDetailNavType.Inventar:
case TrDetailNavType.Fremdleistung:
case TrDetailNavType.Regie:
id = "TagesRapportDetailDummyViewController";
break;
}
_currentViewController = (UIViewController)Storyboard.InstantiateViewController (id);
_currentViewController.View.Frame = containerDetail.Bounds;
AddChildViewController (_currentViewController);
_currentViewController.DidMoveToParentViewController (this);
containerDetail.AddSubview (_currentViewController.View);


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:06/21/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<xamarin.ios><xamarin><uisegmentedcontrol>', 'Title': 'Switching to different UITableViewControllers with UISegementedControl', 'ViewCount': 362, 'id': 17234763, 'user_AboutMe': '', 'user_AccountId': 274590.0, 'user_DisplayName': 'dannyyy', 'user_Reputation': 1714.0, 'user_Views': 138.0, 'user_id': 566913.0}}