gpt4 book ai didi

ios - 在 iOS : Navigation flow not working 中加载不同的 UINavigationController

转载 作者:行者123 更新时间:2023-12-01 18:08:49 24 4
gpt4 key购买 nike

我正在开发通用应用程序,我想为 iPad 和 iPhone 加载不同的文件。

导航流程不起作用。任何帮助表示赞赏。

我正在应用程序委托(delegate)中编写如下代码,

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main"  bundle:nil];
UIViewController *viewController;

UINavigationController *navViewController;




if (IDIOM == IPAD) {
navViewController = [storyboard instantiateViewControllerWithIdentifier:@"ViewController_iPad"];
} else {
navViewController = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
}

// self.window.rootViewController = viewController;
self.window.rootViewController = navViewController;
[self.window makeKeyAndVisible];
return YES;

enter image description here

最佳答案

嘿兄弟试试这个,

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

UINavigationController *navigationController = (UINavigationController *) self.window.rootViewController;

if (IDIOM == IPAD) {
[navigationController pushViewController:[storyboard instantiateViewControllerWithIdentifier:@"ViewController_iPad"] animated:NO];
} else {
[navigationController pushViewController:[storyboard instantiateViewControllerWithIdentifier:@"ViewController"] animated:NO];
}

self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;

关于ios - 在 iOS : Navigation flow not working 中加载不同的 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35861618/

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