2

I just want to show full screen on External Display.

I'm using the code like this:

- (void) startTvOut {
    NSArray *screens = [UIScreen screens];

    CGSize max;
    max.width = 0;
    max.height = 0;
    UIScreenMode *maxScreenMode = nil;
    for (UIScreen *screen in screens)
    {

        if (screen != [UIScreen mainScreen])
        {
            for(int i = 0; i < [[screen availableModes] count]; i++)
            {
                UIScreenMode *current = [[screen availableModes] objectAtIndex: i];
                if (current.size.width > max.width)
                {
                    max = current.size;
                    maxScreenMode = current;
                }
            }
            if (exWindow == nil)
            {
                exWindow = [[HUWindow alloc] initWithFrame:screen.brounds];
                exWindow.backgroundColor = [UIColor whiteColor];
            }
            screen.overscanCompensation = UIScreenOverscanCompensationInsetBounds;
            screen.currentMode = screen.preferredMode;
            exWindow.screen = screen;

            [exWindow makeKeyAndVisible];
            m_isStarted = YES;
        }
    }
}

It can't show full screen on external device.

After I change the code from screen.overscanCompensation = UIScreenOverscanCompensationInsetBounds; to screen.overscanCompensation = UIScreenOverscanCompensationInsetApplicationFrame; it can show full screen, but the point (0,0) is not at the top of left screen.

My goal is to show the screen with full screen and have the point (0, 0) at the upper left corner of the screen. But it doesn't work.

Thanks in advance

yuji
  • 16,695
  • 4
  • 63
  • 64
Alger
  • 41
  • 1
  • 6

2 Answers2

6

Change this line:

screen.overscanCompensation = UIScreenOverscanCompensationInsetBounds;

to

screen.overscanCompensation = 3;

It's a non documented value...

andrewsi
  • 10,807
  • 132
  • 35
  • 51
  • This worked in iOS 9, but doesn't anymore as of iOS 10 – tmm1 Oct 25 '16 at 16:24
  • although this is the best solution, i've noticed that using this value of 3 doesn't guarantee that the screen will be filled. Sometimes yes, sometimes no. Very weird. – horseshoe7 Oct 03 '17 at 13:08
0

For me the following code solved the problem (XCode 4, iOS 12.1)

screen.overscanCompensation = .scale

Before adding this line, I had the problem, that a black frame was around the screen.

mahega
  • 3,231
  • 4
  • 20
  • 32