gpt4 book ai didi

ios - 离开 AVFullScreenViewController 后屏幕不会旋转回纵向

转载 作者:行者123 更新时间:2023-11-28 15:16:27 27 4
gpt4 key购买 nike

使用此代码允许媒体播放器在全屏时横向旋转(应用程序不支持):

// handle orientation for the device
func application (_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
guard let vc = (window?.rootViewController?.presentedViewController) else {
return .portrait
}
if (vc.isKind(of: NSClassFromString("AVFullScreenViewController")!)) || (vc.isKind(of: NSClassFromString("YTPlayerView")!)) {
return .allButUpsideDown
} else {
return .portrait
}
}

ios 10 中工作正常,但自 ios 11 离开全屏后屏幕不会旋转回来,因此不会调整 UI 的大小(旋转后应用程序将只占据一半屏幕)。似乎对 avkit 进行了一些修改,但我找不到这方面的任何资源,想法?

最佳答案

我今天遇到了同样的问题。解决方案是检查iOS11是否正在运行。如果是这样,只需返回 UIInterfaceOrientationMask.portrait 否则返回所需的值。在 iOS 11 中,即使在项目设置中只启用了纵向,视频也可以旋转。

例子:

if #available(iOS 11, *) {
return UIInterfaceOrientationMask.portrait
} else {
guard let vc = (window?.rootViewController?.presentedViewController) else {
return .portrait
}

if (vc.isKind(of: NSClassFromString("AVFullScreenViewController")!)) || (vc.isKind(of: NSClassFromString("YTPlayerView")!)) {
return .allButUpsideDown
} else {
return .portrait
}
}

关于ios - 离开 AVFullScreenViewController 后屏幕不会旋转回纵向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46765537/

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