title: attempt to present a view whose view is not in the window both with segues and programmatically
body: <p>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.</p>
  
  <p>Here are my two versions of code:</p>
  
  <pre><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];
      }
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>- (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];
      }
  }
  </code></pre>
  
  <p>The segue is modal style.</p>
  
  <p>In both cases the NSLog is printed and then I see a warning:</p>
  
  <pre><code>Warning: Attempt to present &lt;LoginScreen: 0x1e5bd010&gt; on &lt;PhotoScreen: 0x1e5b82e0&gt; whose view is not in the window hierarchy!
  </code></pre>
  
  <p>and the new view does not open.</p>
  
  <p>Any hint on that?</p>