gpt4 book ai didi

ios - UIStoryBoard 从 ApplicationDelegate 获取第一个 View Controller

转载 作者:技术小花猫 更新时间:2023-10-29 10:41:49 31 4
gpt4 key购买 nike

我有一个我的 ApplicationDelegate 实现的协议(protocol)。我想将其传递给 Storyboard中定义的第一个 View Controller 。我如何从该方法访问它?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

最佳答案

我不确定我是否正确理解了这个问题我想你是在问如何在 Storyboard 中获得第一个 viewController。为了得到这个你打电话,

UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc =[storybord instantiateInitialViewController];

更改 Storyboard的名称以适合您的名称,MainStoryboard 只是默认名称。希望这就是您要找的。

编辑:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc =[storybord instantiateInitialViewController];
//set the delegate on the view controller that you have loaded
// Override point for customization after application launch.
return YES;
}

关于ios - UIStoryBoard 从 ApplicationDelegate 获取第一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8025248/

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