Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow rotation only in movie player #142

Closed
bitomule opened this issue Jun 7, 2016 · 3 comments
Closed

Allow rotation only in movie player #142

bitomule opened this issue Jun 7, 2016 · 3 comments

Comments

@bitomule
Copy link

bitomule commented Jun 7, 2016

I've a portrait only app but I want to allow rotation inside movie player. Is it possible?

I've tried using this small hack:

let value = UIInterfaceOrientation.Portrait.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")

in viewWillAppear on the presenter view. It works but I see the rotation animation once movie player is dismissed.

Is there any way to allow rotation only inside movie player and once close is pressed rotation is always portrait without any animations?

@uknowmeright
Copy link

uknowmeright commented Aug 24, 2016

try adding this function to your appDelegate:

func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {

    if let navigationController = self.window?.rootViewController as? UINavigationController {

        if navigationController.visibleViewController is MobilePlayerViewController {
            return UIInterfaceOrientationMask.Landscape
        }

        else {
            return UIInterfaceOrientationMask.Portrait
        }
    }

    return UIInterfaceOrientationMask.Portrait
}

@wanewang
Copy link

this is good! it's the best answer AFAIK, nice!

@aloveric
Copy link

Xcode 10 not working when close video, also "Landscape"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants