Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MvvmCross ios UISegmentedControl以显示不同的视图控制器_Ios_Mvvmcross_Uisegmentedcontrol - Fatal编程技术网

MvvmCross ios UISegmentedControl以显示不同的视图控制器

MvvmCross ios UISegmentedControl以显示不同的视图控制器,ios,mvvmcross,uisegmentedcontrol,Ios,Mvvmcross,Uisegmentedcontrol,根据在UISegmentedControl中选择的内容,我需要显示两个不同的视图。我真的不知道从哪里开始。viewcontroller应显示在UISegmentedControl下 所以,我有一个MainViewController,它包含分段控件 和两个视图Child1ViewController和Child2ViewController 我假设需要两个MVXViewController,每个子控件一个,以便在MainViewController中显示,但我不确定在通过分段控件选择它时如何实例

根据在UISegmentedControl中选择的内容,我需要显示两个不同的视图。我真的不知道从哪里开始。viewcontroller应显示在UISegmentedControl下

所以,我有一个MainViewController,它包含分段控件 和两个视图Child1ViewController和Child2ViewController

我假设需要两个MVXViewController,每个子控件一个,以便在MainViewController中显示,但我不确定在通过分段控件选择它时如何实例化和显示它们

我的MainViewModel有显示子视图模型的命令,因为我有一个使用选项卡的对等Android实现,但是如何让它们在包含分段控件的MainViewController中显示呢。创建xib文件时,我无法将UIVIewController放置在XCode中的UIVIewController中


请帮忙

经过几个小时的尝试,我就是这么做的

在我的MainViewController中,对于我需要实例化的每个视图控制器,我调用CreateViewController来创建视图控制器

var child1ViewModelRequest = new MvxViewModelRequest(typeof(Child1ViewModel), null, null. null);
child1View = (Child1View) this.CreateViewControllerFor<Child1ViewModel>(child1ViewModelRequest );
注意currentViewController和child1View是MainViewController的成员变量

currentViewController = (UIViewController)child1View;
this.AddChildViewController(currentViewController);
currentViewController.View.Frame = containerView.Bounds;
containerView.Add(currentViewController.View);