gpt4 book ai didi

ios - 在 iPhone plus 设备上点击横向媒体选择按钮时 AVPlayerViewController 崩溃

转载 作者:可可西里 更新时间:2023-11-01 06:01:08 26 4
gpt4 key购买 nike

标题几乎描述了一切,但在这里详细......要在我的应用程序中播放视频,我使用的是模态呈现的 AVPlayerViewController

let player = AVPlayer.init(url: url)
let playerViewController = AVPlayerViewController.init()
playerViewController.player = player
parentViewController.present(playerViewController, animated: true, completion: {...})

一切正常,视频全屏播放,我可以将设备旋转到横向,然后再旋转回来……一切仍然顺利进行。

当我点击右下角的对话泡泡来更改音频或字幕设置时,这种 UIAlertController 以纵向模式显示(iPhone 7 plus 纵向): audio & subtitle settings in portrait

在横向模式下点击同一个按钮时,它看起来像这样(基本上相同,但会出现在纵向模式下,iPhone 7 横向): audio & subtitle settings launched from landscape but showing in portrait

在横向的 iPad Air 2 上做同样的事情看起来像这样: audio & subtitle settings in landscape on iPad

现在是实际问题:在 6/6s/7 PLUS 设备上以横向模式播放电影并点击对话气泡时,应用程序崩溃了!这是出现在调试器输出和堆栈跟踪中的内容:

2017-08-10 12:08:18.683184+0200 MyApp[27739:6396143] [断言] transitionViewForCurrentTransition 未设置! (<_UIFullscreenPresentationController: 0x7ffe3e586000>) Stack trace

对我来说,这看起来像是一个 Apple bug,因为我在这里没有做任何特别的事情(至少我是这么认为的),而且因为只有在使用 plus 设备时才会出现崩溃,这是唯一具有紧凑和组合的设备常规尺寸类。

有人知道这里发生了什么吗?

最佳答案

我遇到了同样的问题,我用 AppDelegate.m

中的以下代码修复了它
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
for (UIView *transitionView in window.subviews) {
if ([transitionView isKindOfClass:NSClassFromString(@"UITransitionView")]) {
for (UIView *subView in transitionView.subviews) {
id nextResponder = [subView nextResponder];
if ([nextResponder isKindOfClass:NSClassFromString(@"AVFullScreenViewController")]) {
return UIInterfaceOrientationMaskAll;
}
}
}
}
return (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationLandscapeLeft);
}

关于ios - 在 iPhone plus 设备上点击横向媒体选择按钮时 AVPlayerViewController 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45610842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com