2

我只想在外接显示器上全屏显示。

我正在使用这样的代码:

- (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;
        }
    }
}

它无法在外部设备上显示全屏。

在我将代码更改为之后 screen.overscanCompensation = UIScreenOverscanCompensationInsetBounds;screen.overscanCompensation = UIScreenOverscanCompensationInsetApplicationFrame; 它可以显示全屏,但点 (0,0) 不在左屏幕的顶部。

我的目标是全屏显示屏幕,并在屏幕的左上角有点 (0, 0)。但它不起作用。

提前致谢

4

2 回答 2

6

更改此行:

screen.overscanCompensation = UIScreenOverscanCompensationInsetBounds;

screen.overscanCompensation = 3;

这是一个未记录的值...

于 2012-11-17T18:07:30.233 回答
0

对我来说,以下代码解决了这个问题(XCode 4,iOS 12.1)

screen.overscanCompensation = .scale

在添加这条线之前,我遇到了一个问题,屏幕周围有一个黑框。

于 2019-06-27T21:04:52.403 回答