gpt4 book ai didi

objective-c - 以编程方式在委托(delegate)中调用 Storyboard

转载 作者:可可西里 更新时间:2023-11-01 03:26:30 25 4
gpt4 key购买 nike

我正在尝试以编程方式调用我的 Storyboard。我的 Storyboard包括以下内容:

[导航 Controller ] -> [MainMenuView] -> [DetailsView]

“MainMenu”标识符被放置在 [MainMenuView] 中

我遇到的问题是屏幕显示空白。我需要做什么?

谢谢。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

MainMenuView *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"MainMenu"];

return YES
}

最佳答案

需要先手动创建窗口,然后在其中添加rootViewController(之前的回答几乎是正确的):

- (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;
}

关于objective-c - 以编程方式在委托(delegate)中调用 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9828217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com