ios – 从风景iPad推出时,UIViewController在AirPlay屏幕上横向显示

ios – 从风景iPad推出时,UIViewController在AirPlay屏幕上横向显示,第1张

概述我正在尝试使用AirPlay在外部显示器上显示全屏,16:9,UIViewController. 此处的目标是使用自定义视图控制器替换AirPlay镜像,该控制器将跨越外部屏幕的整个大小. 当iPad处于纵向模式时,屏幕连接时,一切似乎都很好.当它在横向连接时,UIViewController在外部显示器上侧向显示,只填充屏幕的一半. 为此,我将我的UIViewController添加到附加的Ai 我正在尝试使用AirPlay在外部显示器上显示全屏,16:9,UIVIEwController.

此处的目标是使用自定义视图控制器替换AirPlay镜像,该控制器将跨越外部屏幕的整个大小.

当iPad处于纵向模式时,屏幕连接时,一切似乎都很好.当它在横向连接时,UIVIEwController在外部显示器上侧向显示,只填充屏幕的一半.

为此,我将我的UIVIEwController添加到附加的AirPlay UIScreen中.

-(voID) screenConnected:(NSNotification * ) notification {    UIScreen * screen = [notification object]; //this should be the airplay display    UIWindow * window = [[UIWindow alloc] initWithFrame:screen.bounds];    [currentwindow setScreen:screen];    UIVIEwController * controller = [_delegate createControllerForAirplaydisplay:window];    [window setHIDden:NO];    [window setRootVIEwController:controller];}

这似乎工作正常,我看到iPad和AirPlay电视全屏显示.

我在哪里看到的问题是当iPad处于横向模式时连接AirPlay显示器.当发生这种情况时,AirPlay显示器会向侧面呈现UIVIEwController,并且看起来像肖像模式.

屏幕连接为纵向:

屏幕连接在横向,内容是侧面的,只在一半的显示器上呈现:

我尝试使用CGAffinetransformMakeRotation旋转UIWindow和UIVIEwController,这确实修复了方向,但视图没有在AirPlay显示内部居中.

编辑

提起与此相关的Apple问题,rdar:// 20817189.如果/当我收到回复时,我会更新此信息.

解决方法 我在文档中找到了这个:
https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/WindowAndScreenGuide/UsingExternalDisplay/UsingExternalDisplay.html

important: Be sure that your app sets the status bar orIEntation correctly. Because the external display can’t read the host device’s accelerometer to respond to changes in orIEntation,it relIEs instead on the status bar orIEntation,as set in your app.

外部UIWindow从当前设备获取方向,在这种情况下是横向方向.
因此,当您设置rootVIEwController的框架时,例如(0,1270,840),原点位于电视的右上角.

您必须以纵向方式强制UIWindow.
我在AppDelegate上使用此代码解决了这个问题:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrIEntationsForWindow:(UIWindow *)_window {if ([UIScreen mainScreen] == _window.screen || !_window) {    return UIInterfaceOrIEntationMaskAll;}else {    return UIInterfaceOrIEntationPortrait;}}
总结

以上是内存溢出为你收集整理的ios – 从风景iPad推出时,UIViewController在AirPlay屏幕上横向显示全部内容,希望文章能够帮你解决ios – 从风景iPad推出时,UIViewController在AirPlay屏幕上横向显示所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1081091.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存