Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.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
Ios 从Xamarin中的代码隐藏创建UIViewController_Ios_Uiviewcontroller_Xamarin_Segue_Code Behind - Fatal编程技术网

Ios 从Xamarin中的代码隐藏创建UIViewController

Ios 从Xamarin中的代码隐藏创建UIViewController,ios,uiviewcontroller,xamarin,segue,code-behind,Ios,Uiviewcontroller,Xamarin,Segue,Code Behind,我目前正在Xamarin中开发一个IOS应用程序。我制作了一个菜单,从codebehind生成4个不同的UIViewController。相反,我想做的是将这些视图推送到我在故事板中设计的、但未连接到当前UIViewController的预制UIViewController 大概是这样的: UIViewController[] control = new UIViewController[DataList.Count]; for (int i = 0; i < control.Lengt

我目前正在Xamarin中开发一个IOS应用程序。我制作了一个菜单,从codebehind生成4个不同的UIViewController。相反,我想做的是将这些视图推送到我在故事板中设计的、但未连接到当前UIViewController的预制UIViewController

大概是这样的:

UIViewController[] control = new UIViewController[DataList.Count];

for (int i = 0; i < control.Length; i++)
{
    if(control[i] == 1)
    {
        control[i] = new ViewControllerGetCar();
        PerformSegue(control[i], null);
    }
    if(control[i] == 2)
    {

    }
}
UIViewController[]control=newuiviewcontroller[DataList.Count];
for(int i=0;i
无法将ViewControllerGetCar转换为UIViewController。。。
它说需要intPtr句柄,我不知道那是什么。我也很确定性能测试不会起作用。有什么想法吗?

如果您在故事板中设计了ViewController,那么下面是正确的实例化方法

MyViewController controller = MyViewController)this.Storyboard.InstantiateViewController("ViewControllerIdentifier");
翻译成你的例子:

UIViewController[] control = new UIViewController[DataList.Count];
for (int i = 0; i < control.Length; i++)
{
  if(control[i] == 1)
  {
    control[i] = this.Storyboard.InstantiateViewController("ViewControllerGetCar"); // <-- presuming that's the identifier you're using for it inside the Storyboard.
    PerformSegue(control[i], null);
  }
  if(control[i] == 2)
  {
    // presumably here another ViewController is specified, etc.
  }
}
UIViewController[]control=newuiviewcontroller[DataList.Count];
for(int i=0;icontrol[i]=this.Storyboard.instantialeviewcontroller(“ViewControllerGetCar”);//您可以包含ViewControllerGetCar的代码吗?我猜,您没有在那里指定正确的构造函数。分部类ViewControllerGetCar:UIViewController{public ViewControllerGetCar(IntPtr handle):base(handle){}谢谢,那个类和构造函数看起来还可以。非常感谢!!!!它工作了,只需要做控制[i]=(UIViewController)这个。情节提要。实例化EWController(“ViewControllerGetCar”);。你为我和我的公司节省了很多时间。完成了!对不起,我是新来的,呵呵。