我的应用程序支持 HDMI 输出。

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

externalScreen.bounds

好的,一切正常。我已经设置了我的 View 并在电视上尝试过......

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

为什么格式不对?

附言当我镜像主屏​​幕时,它也显示条,当我使用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) 初始化我的 View 。

这是我可以在屏幕上看到的 View (注意黑条):

最佳答案

主屏幕会出现黑条,因为纵横比与 16:9 不匹配(我认为是 4:3)。至于外部显示器,请检查主 View 的框架(应该跨越屏幕的 View )。它可能没有设置为 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];

    }
}

关于iphone - iPad 2 上带有 HDMI 适配器的黑条,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10653285/

10-17 03:15