简体   繁体   English

没有情节提要时实例化ViewController

[英]Instantiating a ViewController when there's no storyboard

I have a rather simple iOS app build using MvvmCross .I need to integrate a few screens from a different project. 我有一个使用MvvmCross的相当简单的iOS应用程序构建。我需要集成来自不同项目的一些屏幕。 In said project I'm using a story board and instantiates my view like below 在所说的项目中,我使用一个故事板,实例化如下所示的视图

Storyboard.InstantiateViewController ("Controller")

However when integrated into this particular project it throws because StoryBoard of the ViewController is null. 但是,当集成到此特定项目中时,会抛出该错误,因为ViewController的StoryBoard为null。 So how would one instantiate a controller and have all the subviews laid out in a case like this? 那么,在这种情况下,如何实例化控制器并布置所有子视图?

If your current controller is not created from a storyboard, its Storyboard property is null. 如果当前控制器不是从情节Storyboard创建的,则其Storyboard属性为null。 You can however load the storyboard itself using the static: 但是,您可以使用静态加载情节提要本身:

UIStoryboard.FromName(string name)

This will get you a storyboard reference and from there you can use 这将为您提供一个情节提要参考,您可以从那里使用

InstantiateviewController(string storyboardId)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM