gpt4 book ai didi

ios - 选择最初显示的 ViewController

转载 作者:行者123 更新时间:2023-11-28 22:02:48 25 4
gpt4 key购买 nike

我正在尝试根据 NSUserDefaults BOOL 选择 AppDelegate 应该显示的 ViewController。但是 HomeViewController 不显示。我正在使用 Storyboards,我有自己的 UINavigationController 类。

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

[FBLoginView class];
[FBProfilePictureView class];

MeuNavigationController *nav = [[MeuNavigationController alloc]init];
if ([NSUD boolForChave:@"firstLogin"]==false) {
ViewController *viewC = [[ViewController alloc]init];
[nav pushViewController:viewC animated:NO];
}else{
HomeViewController *viewP = [[HomeViewController alloc]init];
[nav pushViewController:viewP animated:NO];
}

return YES;
}

最佳答案

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

[FBLoginView class];
[FBProfilePictureView class];

UIViewController *controller = nil;
if ([NSUD boolForChave:@"firstLogin"]==false) {
controller = [[ViewController alloc]init];
}else{
controller = [[HomeViewController alloc]init];
}
self.window.rootViewController = [[MenuNavigationController alloc] initWithRootViewController:controller];
[self.window makeKeyAndVisible];

return YES;
}

您注意到您是根据 Storyboard执行此操作的。您可能还想考虑进行此更改:

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

[FBLoginView class];
[FBProfilePictureView class];

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

UIViewController *controller = nil;
if ([NSUD boolForChave:@"firstLogin"]==false) {
controller = [[ViewController alloc]init];
// Set this in the storyboard's identity inspector
controller = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
}else{
controller = [storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
}
self.window.rootViewController = [[MenuNavigationController alloc] initWithRootViewController:controller];
[self.window makeKeyAndVisible];

return YES;
}

但是你问...jakenberg 先生,如何设置他们唯一的 View Controller 标识符?

enter image description here

干杯

关于ios - 选择最初显示的 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24708220/

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