Reputation: 2005
I'm trying to get the UIWindow object of the external screen (such as a television) when using AirPlay mirroring. The tricky part: it really is AirPlay mirroring, not a separate display, as we're using the built-in functionality of AirPlay rather than setting up a new UIWindow object and assigning it to the new screen. My boss wants the app to mirror the device in every way, but to be able to add subviews (tutorial overlays) to the external window exclusively, by adding them to the secondary screen's UIWindow.
What I've Tried:
UIScreenDidConnectNotification
or [UIScreen screens]
, but as far as I know UIScreens don't have references to the UIWindow being shown. [[UIApplication sharedApplication] windows]
, and it doesn't seem to include the UIWindow associated with the external display. (At least, none of the window.screen
objects match the UIScreen object I get from UIScreenDidConnectNotification
when the TV first connects, and while [[UIScreen screens] count]
goes up by 1 when a TV is connected, the count of windows remains static.)Is there a way to access the window for a secondary screen using AirPlay mirroring? Or alternatively, is there a way to efficiently implement app-wide mirroring of the device, that allows greater control of the UIWindow object associated with the TV?
Upvotes: 2
Views: 886
Reputation: 17720
This document from Apple: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/WindowAndScreenGuide/UsingExternalDisplay/UsingExternalDisplay.html
states that:
To re-enable mirroring after displaying unique content, simply remove the window you created from the appropriate screen object.
This means that when mirroring is active, there is no window linked to it, and the mirroring just uses the window of the main screen.
There is only a single window, and I don't think it's possible to show different content in this mode.
If you want to show different content, you'll have to create a new window and assign it to that screen.
Upvotes: 4