以编程方式在委托中调用情节提要 [英] Programmatically call storyboard in delegate
本文介绍了以编程方式在委托中调用情节提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试以编程方式调用我的情节提要. 我的情节提要包括以下内容:
I'm trying to programmatically call my storyboard. My storyboard consists of the following:
[导航控制器]-> [MainMenuView]-> [DetailsView]
[Navigation Controller] -> [MainMenuView] -> [DetailsView]
"MainMenu"标识符位于[MainMenuView]
The "MainMenu" identifier was placed in the [MainMenuView]
我遇到的问题是屏幕显示空白.我该怎么办?
The problem i'm having is the screen showing blank. What do i need to do?
谢谢.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
MainMenuView *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"MainMenu"];
return YES
}
推荐答案
您需要先手动创建窗口,然后在其中添加rootViewController(先前的答案几乎是正确的):
You need to first create the window manually and then add the rootViewController in it (the previous answer was almost correct):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *mainViewController = [storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = mainViewController;
[self.window makeKeyAndVisible];
return YES;
}
这篇关于以编程方式在委托中调用情节提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文