Iphone 在ApplicationIDFinishLaunching中加载UIView

Iphone 在ApplicationIDFinishLaunching中加载UIView,iphone,cocoa-touch,Iphone,Cocoa Touch,我想在第一次加载应用程序时加载UIView。 但我不能让它发生 以下是我的ApplicationIDFinishLaunching方法: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if(![[NSUserDefaults standardUserDefaults] boolForKey:@"Alread

我想在第一次加载应用程序时加载UIView。 但我不能让它发生

以下是我的ApplicationIDFinishLaunching方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    if(![[NSUserDefaults standardUserDefaults] boolForKey:@"AlreadyRan"] ) {
        [[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:@"AlreadyRan"];
        // proceed to do what you wish to only on the first launch
        NarrativeView *narView = [[NarrativeView alloc] initWithNibName:@"NarrativeView" bundle:nil];
        [window addSubview:narView.view];
        [window makeKeyAndVisible];
        [narView release];      
    } else 
    {
        // Override point for customization after application launch.
        [window addSubview:rootController.view];
        [window makeKeyAndVisible];
    }
    return YES;
}

有人能帮我吗?

一种可能是您从未同步NSUserDefault。您需要添加一个
[[NSUserDefaults standardUserDefaults]synchronize]
调用,无论是在那里,还是在applicationWillTerminate和/或ApplicationIdentinterBackground中。

一种可能是您从未同步NSUserDefaults。您需要添加一个
[[NSUserDefaults standardUserDefaults]synchronize]
调用,无论是在那里,还是在applicationWillTerminate和/或ApplicationIdentinterBackground中。

您是否遇到了任何类型的错误,或者您对“AlreadyRan”的测试总是失败,因此您的代码没有执行?您是否遇到了任何类型的错误,或者您的测试是否存在错误“AlreadyRan”总是失败,所以您的代码无法执行?