title: iPad simulator and external screen
body: <p>i have an application that i wish to show on external screen.</p>
  
  <p>The problem is that when i go Hardware -> External displays and select one of them - the events aren't triggered. Why?</p>
  
  <p>This also doesn't get entered:</p>
  
  <pre><code>if ([[UIScreen screens] count] &gt; 1)
  </code></pre>
  
  <p>So i have added next code:</p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
       //SOME CODE ...
       [self checkForExistingScreenAndInitializeIfPresent];
       [self setUpScreenConnectionNotificationHandlers];
       return YES:
  }
  
  - (void)checkForExistingScreenAndInitializeIfPresent
  {
  if ([[UIScreen screens] count] &gt; 1)
  {
      // Get the screen object that represents the external display.
      UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
      // Get the screen's bounds so that you can create a window of the correct size.
      CGRect screenBounds = secondScreen.bounds;
  
      self.secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
      self.secondWindow.screen = secondScreen;
  
      self.externalWindow=[[ExternalDisplayViewController alloc]initWithNibName:@"ExternalDisplayViewController" bundle:nil];
      self.externalWindow.view.frame=screenBounds;
  
      self.secondWindow.rootViewController=self.externalWindow;
      // Set up initial content to display...
      // Show the window.
      self.secondWindow.hidden = NO;
      }
  }
  
  - (void)setUpScreenConnectionNotificationHandlers
  {
  NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
  
  [center addObserver:self selector:@selector(handleScreenDidConnectNotification:)
                 name:UIScreenDidConnectNotification object:nil];
  [center addObserver:self selector:@selector(handleScreenDidDisconnectNotification:)
                 name:UIScreenDidDisconnectNotification object:nil];
  }
  </code></pre>
  
  <p><strong>ADDITION:</strong></p>
  
  <p>Just tried to add code in ViewDidLoad</p>
  
  <p>Added this:</p>
  
  <pre><code>// Check for external screen.
  if ([[UIScreen screens] count] &gt; 1)
  {
  
  }
  else {
  }
  </code></pre>
  
  <p>Have the opened external display and simulator - does't enter the IF block</p>