根视图控制器不会在BOOL上更改

时间:2013-10-20 23:35:08

标签: iphone ios objective-c uiviewcontroller

如果应用程序已打开一次,我正在尝试更改Root View控制器。这是我正在做的事情。布尔是完全正常的,我知道因为它打印'欢迎回来'。这就是我想要做的事情。

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

1 个答案:

答案 0 :(得分:0)

好像你没有正确设置/更新应用程序窗口。我创建了一个可能有帮助的示例项目。 https://github.com/deepthit/UpdateRootViewController.git

相关问题