title: Apple TV as an external UIScreen on an iOS device
body: <p>I have an app that displays video in a subview and where it would be nice to give the option to display that video on a second screen such as an Apple TV and be able to use that freed-up space to show additional controls.</p>
  
  <p>I've found all sorts of help about how to do that, but I'm hitting a wall even before getting out of the starting gate.</p>
  
  <p>In order to detect that the app has started up in a multiple display environment, all the sample code features a line like...</p>
  
  <pre><code>if (UIScreen.Screens.Length &gt; 1) {
      // ...
  }
  </code></pre>
  
  <p>(I'm doing this in C#/Xamarin, though I doubt the problem is related to that; anyway, the snippets are in C#)</p>
  
  <p>My problem is that the array of screens is always 1 no matter what I do. The iPad is running iOS 11.2.5, and if I turn on mirroring, the iPad is mirrored, but , again, the array of screens only has a single item.</p>
  
  <p>There are also a couple of observers to detect screens being added/removed while the app is running. I haven't seen Xamarin specific code, but I presume it looks like:</p>
  
  <pre><code>NSNotificationCenter.DefaultCenter.AddObserver(this, UIScreen.DidConnectNotification, NSKeyValueObservingOptions.New, IntPtr.Zero);
  NSNotificationCenter.DefaultCenter.AddObserver(this, UIScreen.DidDisconnectNotification, NSKeyValueObservingOptions.New, IntPtr.Zero);
  </code></pre>
  
  <p>Anyway, those never fire even if I add/remove the Apple TV or enter/exit Mirroring Mode on the iPad.</p>
  
  <p>Oh; also if I do</p>
  
  <pre><code>avPlayer.AllowsExternalPlayback = true;
  avPlayer.UsesExternalPlaybackWhileExternalScreenIsActive = true;
  </code></pre>
  
  <p>then that works as expected, too. The video now appears full-screen on the Apple TV and the UIView on the iPad containing the avPlayer greys out rather than showing the video.</p>
  
  <p>However, that's not what I'm looking for. I would like to control the layout of both screens and that does neither. (While I do want the video to be full screen on the Apple TV, I don't want it to be an AVPlayerViewController and I do want to repurpose the screen real-estate taken up by the iPad video view)</p>
  
  <p>At the end of the day, all I think I need is to manage to get</p>
  
  <p>UIScreen.Screens.Length to be equal to 2 when I launch the app.</p>
  
  <p>What's the secret of getting UIScreen to detect/report a second display?</p>