I'm fairly new to iOS programming and I'm working on an iPad app that has a Tab Bar Controller with 4 View Controllers (named FirstViewController, SecondViewController, etc) attached to it. Currently the Tab Bar Controller is set to be the default starting point of the app. I want to be able to authenticate the user before they reach that point, so I've added another View Controller called LoginViewController that is floating by itself in the Storyboard.
What I want to do is allow the app to load and in didFinishLaunching, display the login page until authentication is complete, then dismiss it. I've been searching around for the past couple days, but everything I've been trying has failed.
My most current attempt was
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
UINavigationController *loginVC = [storyboard instantiateViewControllerWithIdentifier:@"loginVC"];
loginVC.modalPresentationStyle = UIModalPresentationFullScreen;
[self.window.rootViewController presentModalViewController:loginVC animated:YES];
Any help would be appreciated. It compiles and runs, but the view is not showing up at all and I really confused as to why this is happening.
The problem was I was trying to instantiate it as a UINavigationController, when in fact it was just a UIViewController. Calling this in applicationDidBecomeActive in appDelegate.m did the trick.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *loginVC = [storyboard instantiateViewControllerWithIdentifier:@"loginVC"];
loginVC.modalPresentationStyle = UIModalPresentationFullScreen;
[self.window.rootViewController presentModalViewController:loginVC animated:YES];