I'm attempting to display a full screen, 16:9, UIViewController
on an external display using AirPlay.
The goal here is to replace AirPlay mirroring with a custom view controller that will span the full size of the external screen.
Everything seems to work great when the screen connects while the iPad is in portrait mode. When it connects in landscape, the UIViewController
shows up sideways on the external display and only fills half the screen.
In order to this I'm adding my UIViewController
to the attached AirPlay UIScreen
.
-(void) screenConnected:(NSNotification * ) notification {
UIScreen * screen = [notification object]; //this should be the airplay display
UIWindow * window = [[UIWindow alloc] initWithFrame:screen.bounds];
[currentWindow setScreen:screen];
UIViewController * controller = [_delegate createControllerForAirplayDisplay:window];
[window setHidden:NO];
[window setRootViewController:controller];
}
This seems to work fine, I see a full screen display on the iPad as well as the AirPlay TV.
Where I'm seeing an issue is when the AirPlay display is connected while the iPad is in landscape mode. When this happens the AirPlay display renders the UIViewController
sideways and in what looks like portrait mode.
Screen connected in portrait:
Screen connected in landscape, content is sideways and only rendered on half the display:
I've attempted rotating the UIWindow
and UIViewController
using CGAffineTransformMakeRotation
, this does fix the orientation but the view is not centered inside the AirPlay display.
Edit
Filed an issue with Apple related to this, rdar://20817189. I will update this if/when I hear back.