2

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?

tuledev
  • 10,177
  • 4
  • 29
  • 49
Tony Hematite
  • 149
  • 3
  • 14

3 Answers3

0

You can get the screen size like this:

    UIScreen *secondaryScreen = [UIScreen screens][1];
    UIScreenMode *secondaryScreenMode = [[secondaryScreen availableModes] objectAtIndex: 0];
    CGSize sizeSecendaryScreen = secondaryScreenMode.size;
    screenWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0,0, sizeSecendaryScreen.width, sizeSecendaryScreen.height)];

Ref: Setting UIScreen's mode / resolution

Community
  • 1
  • 1
tuledev
  • 10,177
  • 4
  • 29
  • 49
0

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?

Community
  • 1
  • 1
Tony Hematite
  • 149
  • 3
  • 14
0

In my case there was no launch image for perticular resolution for which I want to support. For example : If you want to support iPhone5 we need to add launch image of the size of iPhone5. Please check in your Xcode whether you have all required launch images or not. This may be your solution. In my case it worked for me!

Anil Kukadeja
  • 1,348
  • 1
  • 14
  • 27