title: How to call a view controller from AppDelegate in iOS
body: <p>I am creating an iOS app in which I have the following requeriment: the app should show the login screen when it starts the first time and also that screen must also be shown when the app comes from the background to the foreground, in case it has been sent to background during run time. </p>
  
  <p>I have handled to show the screen in both cases. However, when I do it and the app comes from the background, and I click the texfield to type my password, the app gets frozen, and it fails in a thread that I don't know what it means.</p>
  
  <p>I call the screen to be shown when the app comes from background like this, in the applicationWillEnterForeground, in AppDelegate:</p>
  
  <pre><code>self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  RoomRootViewController* room = [[RoomRootViewController alloc] init];
  [[self window] setRootViewController:room];
  [self.window makeKeyAndVisible];
  </code></pre>
  
  <p>Is this the correct way to do so?</p>
  
  <p>Thanks a lot in advance ! I am completely lost with this as I am very new in iOS, so any help will be very appreciated.</p>
  
  <p>Attached in an image you can see where the app fails. <img src="https://i.stack.imgur.com/jI86o.png" alt="Screenshot of the thread where the app fails"></p>
  
  <p><img src="https://i.stack.imgur.com/TXYAm.png" alt="Screenshot of the tracking made to interpret the thread issue"></p>