2012-05-18 28 views
3

我的应用程序支持HDMI输出。带有iPad 2上的HDMI适配器的黑条

我问了代号为电视的分辨率,并得到1920×1080像素的

externalScreen.bounds 

OK,一切正常。我设置我的意见,并尝试了在电视上...

但是:黑条底部/顶/虽然正确检测到电视屏幕的两侧为1920×1080,并我的看法也设置正确?

为什么格式错了?

P.S.当我镜像主屏​​幕时,它还会显示酒吧,当我用Youtube应用程序观看视频时,黑条消失了吗?

谢谢你的帮助!

更新:

OK,但我得到这个输出在我的控制台:

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

回答

1
externalScreen.overscanCompensation = UIScreenOverscanCompensationInsetApplicationFrame; 
4

主屏幕将有黑边,因为长宽比不匹配16:9(这是4:3我认为)。就外部显示器而言,检查主视图的框架(应该跨越屏幕的视图)。这可能是未设置为1920×1080

编辑:我用这个代码的一个项目,我必须输出从iPad的1920×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]; 

    } 
} 
+0

我做了:'mainView.frame = externalScreen.bounds'模拟器正确地完成了它。 – DAS

+0

看到我的编辑。我添加了过去成功使用的screenDidConnect函数。 – Dima

+0

到目前为止,谢谢你。请看看我的编辑。 – DAS

1

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

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

只要将它设置为UIScreenOverscanCompensationInsetApplicationFrame可能导致的一个UIWindow内容错位。

相关问题