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.
精彩评论