【问题标题】:Show full screen on External Display for iOS在 iOS 外接显示器上全屏显示
【发布时间】:2019-06-28 05:04:52
【问题描述】:

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

我正在使用这样的代码:

- (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)。但它不起作用。

提前致谢

【问题讨论】:

    标签: ios external-display


    【解决方案1】:

    改变这一行:

    screen.overscanCompensation = UIScreenOverscanCompensationInsetBounds;
    

    screen.overscanCompensation = 3;
    

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

    【讨论】:

    • 这在 iOS 9 中有效,但在 iOS 10 中不再有效
    • 虽然这是最好的解决方案,但我注意到使用这个值 3 并不能保证屏幕会被填满。有时是,有时不是。很奇怪。
    【解决方案2】:

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

    screen.overscanCompensation = .scale
    

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

    【讨论】:

      猜你喜欢
      • 2014-02-01
      • 2010-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多