[英]How to Initialize ViewController from LaunchScreen.Storyboard
When I try to instantiate ViewController from Main.Storyboard in another ViewController I doing something like this: 当我尝试在另一个ViewController中从Main.Storyboard实例化ViewController时,我会执行以下操作:
SplashViewController splashVC = Storyboard.InstantiateViewController("Splash") as SplashViewController;
Where Storyboard is "the UIStoryboard from which this UIViewController was created". Storyboard是“创建此UIViewController的UIStoryboard”。
However, I need to Instantiate ViewController from LaunchScreen.Storyboard at this time. 但是,此时我需要从LaunchScreen.Storyboard实例化ViewController。
You should not write code in LaunchScreen.Storyboard
if you need to start your application immediately you can write your code FinishedLaunching
as it is first method to be called soon after Launching. 如果您需要立即启动应用程序,则不要在
LaunchScreen.Storyboard
编写代码,可以编写代码FinishedLaunching
因为它是启动后不久要调用的第一种方法。 Write your code here. 在此处编写您的代码。
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;
}
No, you can't Instantiate ViewController from LaunchScreen.Storyboard. 不,您不能从LaunchScreen.Storyboard实例化ViewController。
The launch screen is what first appears when the user taps the app icon before the app is finished launching. 启动屏幕是在应用程序完成启动之前用户点击应用程序图标时首先出现的屏幕。 It shows a single, static screen.
它显示单个静态屏幕。 It can't be dynamic and it can't use any custom classes or code.
它不能是动态的,也不能使用任何自定义类或代码。
And 和
You cannot specify a custom class name in the storyboard and expect the system to give you the option to execute code at this stage by calling viewDidLoad.
您无法在情节提要中指定自定义类名称,并且不能期望系统在此阶段通过调用viewDidLoad为您提供执行代码的选项。 Remember, the app hasn't launched yet.
请记住,该应用尚未启动。
Refer: replacing-launch-images-with-storyboards 请参阅: 用故事板替换启动图像
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.