For some reason, whenever I try to run my app, the app will always go to LoginViewController even though it's supposed to go to ViewController when passwordCheck has a non-null value.
Warning: Attempt to present <UINavigationController: 0x14570ff0> on <LoginViewController: 0x1465ea00> whose view is not in the window hierarchy!
This was working before until I switched to using Storyboards from .xib files. Here's the code that I have (it is currently in LoginViewController.m.
if (passwordCheck) {
NSLog(@"%@", usernameField.text);
// Persist the Username for recovery later
[[NSUserDefaults standardUserDefaults] setObject:usernameField.text forKey:kUsernameDefaultsKey];
[[NSUserDefaults standardUserDefaults] synchronize];
NSError *error = nil;
[STKeychain storeUsername:[NSString stringWithFormat:@"%@", usernameField.text] andPassword:[NSString stringWithFormat:@"%@", passwordField.text] forServiceName:@"LoginApp" updateExisting:YES error:&error];
ViewController *viewControl = [self.storyboard instantiateViewControllerWithIdentifier:@"MainControllerNav"];
// Send username to ViewController
AppDelegate *dataCenter = (AppDelegate *) [[UIApplication sharedApplication] delegate];
dataCenter.usernameData = usernameField.text;
NSLog(@"%@", dataCenter.usernameData);
viewControl.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:viewControl animated:YES completion:nil];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
} else {
NSLog(@"Finish viewDidLoad and wait for future instructions from user.");
}
I tried to fix it using this answer, but neither have been helpful. How do I solve this? Thank you in advance.