I want to open a login screen and I have tried both programmatically and both with a segue. I have seen similar questions but it didn't fix it for me.
Here are my two versions of code:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
if (![[API sharedInstance] isAuthorized]) {
NSLog(@"I should Open login screen");
[self performSegueWithIdentifier:@"ShowLogin" sender:nil];
}
}
or
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
if (![[API sharedInstance] isAuthorized]) {
NSLog(@"I should Open login screen");
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
LoginScreen *vc = [sb instantiateViewControllerWithIdentifier:@"LoginScreen"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
}
}
The segue is modal style.
In both cases the NSLog is printed and then I see a warning:
Warning: Attempt to present <LoginScreen: 0x1e5bd010> on <PhotoScreen: 0x1e5b82e0> whose view is not in the window hierarchy!
and the new view does not open.
Any hint on that?