Alger
Alger

Reputation: 41

Show full screen on External Display for iOS

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

Upvotes: 2

Views: 2762

Answers (2)

mahega
mahega

Reputation: 3311

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.

Upvotes: 0

Change this line:

screen.overscanCompensation = UIScreenOverscanCompensationInsetBounds;

to

screen.overscanCompensation = 3;

It's a non documented value...

Upvotes: 6

Related Questions