Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iPad2上带有HDMI适配器的黑条_Iphone_Ios_Xcode_Ipad_Hdmi - Fatal编程技术网

Iphone iPad2上带有HDMI适配器的黑条

Iphone iPad2上带有HDMI适配器的黑条,iphone,ios,xcode,ipad,hdmi,Iphone,Ios,Xcode,Ipad,Hdmi,我的应用程序支持HDMI输出 我询问了电视分辨率的代码,得到了1920 x 1080像素的分辨率 externalScreen.bounds 好的,一切都好。我已经设置了我的视图并在电视上尝试了 但是:尽管电视被正确检测为1920 x 1080,并且我的视图也被正确设置,但屏幕的底部/顶部/侧面仍有黑色条 为什么格式不对 另外,当我镜像主屏幕时,它也会显示条,当我使用Youtube应用程序观看视频时,黑色条会消失吗 谢谢你的帮助 更新: 好的,虽然我在控制台中得到了这个输出: A new sc

我的应用程序支持HDMI输出

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

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

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

为什么格式不对

另外,当我镜像主屏幕时,它也会显示条,当我使用Youtube应用程序观看视频时,黑色条会消失吗

谢谢你的帮助

更新:

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

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)初始化视图

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


主屏幕将有黑色条,因为纵横比不匹配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];

    }
}

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

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

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

我这样做了:
mainView.frame=externalScreen.bounds
模拟器操作正确。请参阅我的编辑。我添加了过去成功使用过的screenDidConnect功能。尝试设置externalScreen.overscanCompensation=3起初我以为黑条只在侧面,但你的照片显示它无处不在,该属性应该可以修复它。这使它能够工作:
externalScreen.overscanCompensation=UIScreenOverscanCompensationInsetApplicationFrame
externalScreen.overscanCompensation = UIScreenOverscanCompensationInsetBounds | UIScreenOverscanCompensationInsetApplicationFrame; // this is the same as setting it to 3