开发者

Load UIView in applicationdidFinishLaunching

I want to load a UIView, first time my app loads. But I can't make it happen.

Here's my applicationdidFinishLaunching method:

- (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:rootControlle开发者_StackOverflow社区r.view];
        [window makeKeyAndVisible];
    }
    return YES;
}

Can some one help me here?


A possibility is that you never synchronize the NSUserDefaults. You need to add a [[NSUserDefaults standardUserDefaults] synchronize] call, either right there, or in applicationWillTerminate and/or applicationDidEnterBackground.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜