简体   繁体   English

根视图控制器在BOOL上未更改

[英]Root View Controller not changing on BOOL

I am trying to change the Root View controller if the application has been opened once. 如果应用程序已打开一次,我试图更改Root View控制器。 Here is what im doing. 我在做什么。 The boolean is fully functional and i know because it prints 'Welcome Back'. 布尔函数功能齐全,我知道,因为它显示“ Welcome Back”。 Here is what im trying to do. 这是我正在尝试做的事情。

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"])
    {
        // App Already launched
        RootMenuController *viewController = [[RootMenuController alloc] init];
        [UIApplication sharedApplication].keyWindow.rootViewController = viewController;
    }
    else
    {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        // This is the first launch ever

    }

        [self.window makeKeyAndVisible];

    return YES;
}

It seems like you are not setting/updating application window properly. 似乎您没有正确设置/更新应用程序窗口。 I have created an sample project which might help. 我创建了一个示例项目,可能会有所帮助。 https://github.com/deepthit/UpdateRootViewController.git https://github.com/deepthit/UpdateRootViewController.git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM