首页 > 解决方案 > 如何从 LaunchScreen.Storyboard 初始化 ViewController

问题描述

当我尝试在另一个 ViewController 中从Main.Storyboard实例化 ViewController 时,我会执行以下操作:

SplashViewController splashVC = Storyboard.InstantiateViewController("Splash") as SplashViewController;

Storyboard 是“创建此 UIViewController 的 UIStoryboard”。

但是,此时我需要从 LaunchScreen.Storyboard实例化 ViewController 。

标签: c#xamarin.iosstoryboard

解决方案


LaunchScreen.Storyboard如果您需要立即启动应用程序,则不应编写代码,您可以编写代码FinishedLaunching,因为它是启动后不久调用的第一个方法。在这里写下你的代码。

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    // Override point for customization after application launch.
    // If not required for your application you can safely delete this method

    return true;
}

推荐阅读