I have a similar problem as the user “Flocked” (see question here: Load an other View from applicationDidFinishLaunching in the AppDelegate), but after reading his post I didn’t manage to work it out, maybe my situation is different from his.
I have inside my didFinishLaunchingWithOptions a routine for checking if the application is run for the first time (also taken from another user):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
}
else{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstLaunch"];
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]) {
NSLog(@"First run");
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I can’t manage to load another view, InfoView (a view for setup) if firstLaunch occurs.
I have tried:
InfoView *infoView = [[InfoView alloc]init];
[self presentViewController:infoView animated:YES completion:nil];
inside if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"])
but no luck. Any ideas or help?
Try this: