【发布时间】:2023-04-04 08:55:02
【问题描述】:
我正在尝试使用 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。如果/当我收到回复时,我会更新此内容。
【问题讨论】:
-
有趣。升级到 IOS 8.3 后,我又开始看到同样的问题。现在我分享你的烦恼。您收到 Apple 票的回复了吗?
-
@ganta 票上什么也没有
标签: ios objective-c ipad airplay