【问题标题】:Black bars with HDMI Adapter on iPad 2iPad 2 上带有 HDMI 适配器的黑条
【发布时间】:2012-05-26 01:36:01
【问题描述】:

我的应用支持 HDMI 输出。

我询问了电视分辨率的代码,得到了 1920 x 1080 像素

externalScreen.bounds

好的,一切都很好。我已经设置好视图并在电视上进行了尝试...

但是:尽管电视被正确检测为 1920 x 1080 并且我的视图也已设置,但屏幕底部/顶部/侧面有 黑条正确吗?

为什么格式不对?

附:当我镜像主屏​​幕时,它也显示了条,当我使用 Youtube App 观看视频时,黑条消失了?

感谢您的帮助!

更新:

好的,虽然我在控制台中得到了这个输出:

A new screen got connected: <UIScreen: 0x3439a0; bounds = {{0, 0}, {1920, 1080}}; mode = <UIScreenMode: 0x345240; size = 1920.000000 x 1080.000000>>

...我仍然得到黑框。出于测试目的,我使用 CGRectMake(0.0f,0.0f,1920.0f,1080.0f) 初始化我的视图。

这是我在屏幕上看到的视图(注意黑条):

【问题讨论】:

    标签: iphone ios xcode ipad hdmi


    【解决方案1】:

    主屏幕会出现黑条,因为纵横比与 16:9 不匹配(我认为是 4:3)。至于外部显示器,请检查主视图的框架(应该跨越屏幕的视图)。它可能未设置为 1920 x 1080

    编辑:我将此代码用于一个项目,我必须从 iPad 输出到 1920 x 1080 显示器并且它工作正常

    - (void) screenDidConnect:(NSNotification *)aNotification
    {
        NSLog(@"A new screen got connected: %@", [aNotification object]);
        //[self printScreenInfo];
    
        UIScreen* newScreen = [aNotification object];
    
        CGRect screenBounds = newScreen.bounds;
    
        if (!self.externalWindow)
        {
            self.externalWindow = [[UIWindow alloc] initWithFrame:screenBounds];
    
            self.externalWindow.screen = newScreen;
            self.externalViewController.view.frame = externalWindow.frame;
    
            [self.externalWindow addSubview:externalViewController.view];
    
            self.externalWindow.hidden = NO;
            // Set the initial UI for the window.
            // [externalViewController displaySelectionInSecondaryWindow:externalWindow];
    
        }
    }
    

    【讨论】:

    • 我做到了:mainView.frame = externalScreen.bounds 模拟器正确地做到了。
    • 查看我的编辑。我添加了我过去成功使用的 screenDidConnect 函数。
    • 尝试设置 externalScreen.overscanCompensation = 3
    • 起初我以为黑条只是在侧面,但你的照片告诉我它到处都是,该属性应该修复它。
    • 这使它工作:externalScreen.overscanCompensation = UIScreenOverscanCompensationInsetApplicationFrame;
    【解决方案2】:
    externalScreen.overscanCompensation = UIScreenOverscanCompensationInsetApplicationFrame;
    

    【讨论】:

      【解决方案3】:

      最适合大多数电视的设置是:

      externalScreen.overscanCompensation = UIScreenOverscanCompensationInsetBounds | UIScreenOverscanCompensationInsetApplicationFrame; // this is the same as setting it to 3
      

      仅将其设置为 UIScreenOverscanCompensationInsetApplicationFrame 可能会导致 UIWindow 内容不对齐。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-20
        • 2019-04-11
        • 2017-06-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多