Ios 全屏播放的AVPlayer不';t旋转

Ios 全屏播放的AVPlayer不';t旋转,ios,swift,orientation,avplayer,avplayerviewcontroller,Ios,Swift,Orientation,Avplayer,Avplayerviewcontroller,在我们的项目中,我们已经阻止/取消阻止了视图的方向,并在下面插入了代码。一切都很好 AppDelegate.swift func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask { if let rootViewController = self.topViewControl

在我们的项目中,我们已经阻止/取消阻止了视图的方向,并在下面插入了代码。一切都很好

AppDelegate.swift

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
    if let rootViewController = self.topViewControllerWithRootViewController(window?.rootViewController) {
        if (rootViewController.respondsToSelector(Selector("canRotate"))) {
            // Unlock landscape view orientations for this view controller
            return .AllButUpsideDown;
        }
    }

    // Only allow portrait (standard behaviour)
    return .Portrait;
}

private func topViewControllerWithRootViewController(rootViewController: UIViewController!) -> UIViewController? {
    if (rootViewController == nil) { return nil }
    if (rootViewController.isKindOfClass(UITabBarController)) {
        return topViewControllerWithRootViewController((rootViewController as! UITabBarController).selectedViewController)
    } else if (rootViewController.isKindOfClass(UINavigationController)) {
        return topViewControllerWithRootViewController((rootViewController as! UINavigationController).visibleViewController)
    } else if (rootViewController.presentedViewController != nil) {
        return topViewControllerWithRootViewController(rootViewController.presentedViewController)
    }
    return rootViewController
}
...
ViewController.swift

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func viewWillDisappear(animated : Bool) {
        super.viewWillDisappear(animated)

        if (self.isMovingFromParentViewController()) {
            UIDevice.currentDevice().setValue(Int(UIInterfaceOrientation.Portrait.rawValue), forKey: "orientation")
        }
    }

    func canRotate() -> Void {}
}

该应用程序只是纵向的,除了一个视图,我们已经启用了所有的方向。在这个视图中,还有一个带有AVPlayer的容器,问题是我不知道如何在这个avplayervewcontroller中启用所有方向。该应用程序允许在包含播放器的视图中显示所有方向,但一旦我将播放器全屏显示,该应用程序就不会旋转。我已经尝试使用容器中AVPlayer的AVPlayerViewController中前面提到的代码,但是播放器没有旋转

@matt我们尝试了几十篇帖子,但都没有成功,但这告诉你什么?它告诉你,再次问同样的问题不会增加任何东西。