我有一个应用程序使用UISplitViewController
在详细信息视图控制器中加载网页,该网页具有WKWebView
属性。有些网址是嵌入式YouTube视频的链接,有些是直接链接到.mp4文件。无论哪种方式,视频文件都会自动加载(在点击YouTube视频之后)到全屏系统播放器中,我假设是AVPlayerViewController
。我已经看过几篇关于通过实施AVPlayerViewController
进行子类化supportedInterfaceOrientations
以允许轮换的帖子,以及其他建议检查UIWindow
' {{{在rootViewController
中{}} presentedViewController
或检查application: supportedInterfaceOrientationsForWindow:
上显示AppDelegate
时的变量,但这些解决方案都没有对我有用,因为我&# 39;我没有创建或展示我自己的AVPlayerViewController
实例,所以我不确定在播放这些视频时如何让旋转成为横向。
当系统以全屏模式播放视频时,有什么办法可以判断,我可以允许旋转吗?
以下是我已经看过的一些帖子的链接:
答案 0 :(得分:2)
我希望你还需要一个答案。我在Swift中找到了解决方案,但它只是在Objective C中可以转换。我发现,当使用WKWebView(也许是UIWebView)时,全屏视频会在新的UIWindow中呈现(至少在iOS 10上)。该窗口有空白 UIViewController ,并在其上显示 AVFullScreenViewController 。
所以,在你的AppDelegate中你应该像这样实现func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if window != self.window, let pvc = window?.rootViewController?.presentedViewController, "\(type(of: pvc))" == "AVFullScreenViewController" {
return pvc.isBeingDismissed ? .portrait : .all
}
return .portrait
}
"AVFullScreenViewController"
虽然 AVFullScreenViewController 是私有API类,但您可以保护自己并将String(format: "AV%@ViewController", "FullScreen")
替换为 app.controller("blankCtrl", ['$scope', '$http', '$parse',
function($scope, $http, $parse) {
$scope.login = function() {
$scope.spice = 'tooo';
alert("hiii");
$.ajax({
url : "http://edudux.com/manage/index.php?/api/login",
dataType:"json",
success:function(data)
{
alert("mobile:"+data.mobile+"\npassword:"+data.password);
}
});
}
}]);