iPad 2上带有HDMI适配器的黑条

时间:2012-05-18 13:10:50

标签: iphone ios xcode ipad hdmi

我的应用支持HDMI输出。

我问了电视分辨率的代码,并获得了1920 x 1080 px

externalScreen.bounds
好的,一切都很好。我设置了自己的观点,并在电视上试了一下......

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

为什么格式错误?

P.S。当我镜像主屏​​幕时,它也会显示条形图,当我用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)初始化我的视图。

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

enter image description here

3 个答案:

答案 0 :(得分:4)

主屏幕将显示黑条,因为宽高比与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];

    }
}

答案 1 :(得分:1)

externalScreen.overscanCompensation = UIScreenOverscanCompensationInsetApplicationFrame;

答案 2 :(得分:1)

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

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

将其设置为UIScreenOverscanCompensationInsetApplicationFrame会导致UIWindow内容错位。