I want to place content on an external screen (for now a MacBook Pro using Air Server) in full screen, with a screen on a tablet.
I am using an example from https://github.com/quellish/AirPlayStoryboards - which is great. However, I am finding that neither screen is displaying the full screen because the UIScreen's bounds are coming back too small -- the iPad displays a little smaller (letterboxed) and the iPad screen only displays 1/4 of the screen in the top left (origin)
Any idea why this is? The code:
- (void) application:(UIApplication *)__unused application didConnectScreen:(UIScreen *) screen
{
UIStoryboard *storyboard = nil;
UIWindow *screenWindow = nil;
UIViewController *tvViewController = nil;
// Set up external screen
UIScreen *secondaryScreen = [UIScreen screens][1];
UIScreen *primaryScreen = [UIScreen screens][0];
NSLog(@"Screen 1 (iPad): %@", primaryScreen); //print the bounds of the iPad
NSLog(@"Screen 2 (MacBook): %@:", secondaryScreen); //print the bounds and size of the MacBook
UIScreenMode *screenMode = [[secondaryScreen availableModes] lastObject];
CGRect bounds = secondaryScreen.bounds;
// Create new outputWindow
screenWindow = [[UIWindow alloc] initWithFrame:bounds];
screenWindow.screen = secondaryScreen;
screenWindow.screen.currentMode = screenMode;
[screenWindow makeKeyAndVisible];
[screenWindow setScreen:screen];
storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle bundleForClass:[self class]]];
tvViewController = [storyboard instantiateViewControllerWithIdentifier:@"TVViewController"];
[screenWindow setClipsToBounds:YES];
[screenWindow setRootViewController:tvViewController];
[screenWindow setHidden:NO];
// // If you do not retain the window, it will go away and you will see nothing.
[[self windows] addObject:screenWindow];
}
The Log statements return as follows:
Screen 1 (iPad): <UIScreen: 0x1567def0; bounds = {{0, 0}, {480, 320}}; mode = <UIScreenMode: 0x1567dd60; size = 1024.000000 x 768.000000>>
Screen 2 (MacBook): <UIScreen: 0x15680280; bounds = {{0, 0}, {640, 400}}; mode = <UIScreenMode: 0x156804a0; size = 1280.000000 x 800.000000>>:
Does anyone know how I may fix this issue?
I figured this out. It was to do with [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8. I got the clue from this post:
Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?