UIViewController is displayed on the side of the AirPlay screen when launched from the landscape iPad

I am trying to display a full screen, 16: 9, UIViewControlleron an external display using AirPlay.

The goal here is to replace AirPlay mirroring with a custom view controller that will cover the full size of the external screen.

Everything seems to work just fine when the screen connects when the iPad is in portrait mode. When it is connected in the landscape, it is UIViewControllerdisplayed on the side of the external display and fills only half of the screen.

To do this, I add my own UIViewControllerto 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];

}

Everything seems to be working fine, I see a full-screen display on the iPad, as well as AirPlay TV.

, AirPlay , iPad . , AirPlay UIViewController , .

, :

Launched in portrait, displays ok

, , :

Launched in landscape, displays sideways

UIWindow UIViewController CGAffineTransformMakeRotation, , AirPlay.

Edit

Apple , rdar://20817189. , / .

+4
3

: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/WindowAndScreenGuide/UsingExternalDisplay/UsingExternalDisplay.html

: , . -, , , .

UIWindow , . , , (0, 0, 1270, 840), .

UIWindow . AppDelegate:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)_window {
if ([UIScreen mainScreen] == _window.screen || !_window) {
    return UIInterfaceOrientationMaskAll;
}else {
    return UIInterfaceOrientationPortrait;
}
}
+9

shouldAutorotateToInterfaceOrientation YES, .

0

Airplay windows installed in Portrait Mask will never rotate. The default status bar is Portrait, so the rotation value is based on this. Here is an example of code that works (suppose you save your Airplay UIWindow as self.secondWindow on your AppDelegate when you connect it)

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    if(window == self.secondWindow){
        return UIInterfaceOrientationMaskPortrait;
    }
    return UIInterfaceOrientationMaskAll;
}
0
source

All Articles