黑色酒吧与iPad 2上的HDMI适配器
我的应用程序支持HDMI输出。
我问代码的电视分辨率,得到了1920 x 1080像素
externalScreen.bounds
好的,一切都很好。 我已经设置了我的意见,并尝试在电视上…
但是:屏幕底部/顶部/侧面有黑条 ,虽然电视被正确检测为1920 x 1080,我的视图也设置正确?
为什么格式错了?
PS当我镜像主屏幕时,它也显示酒吧,当我用Youtube应用程序观看video时,黑条消失了吗?
感谢您的帮助!
更新:
好的,虽然我的控制台里有这个输出:
A new screen got connected: <UIScreen: 0x3439a0; bounds = {{0, 0}, {1920, 1080}}; mode = <UIScreenMode: 0x345240; size = 1920.000000 x 1080.000000>>
…我仍然得到黑框。 为了testing目的CGRectMake(0.0f,0.0f,1920.0f,1080.0f)
我使用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 = UIScreenOverscanCompensationInsetApplicationFrame;
最适合大多数电视的设置是:
externalScreen.overscanCompensation = UIScreenOverscanCompensationInsetBounds | UIScreenOverscanCompensationInsetApplicationFrame; // this is the same as setting it to 3
只要将其设置为UIScreenOverscanCompensationInsetApplicationFrame,就可能导致UIWindow内容未alignment。