Search code examples
iphoneiosmpmovieplayercontroller

MPMoviePlayerController does not change Orientation in full-Screen mode in iOS 5


In my app i support only portrait mode and use UINavigationController as RootViewController. But when i am playing movie using MPMoviePlayerController and Player is Fullscreen than i want it to support both landscape mode Also.

Does this using this great code by @ChrisBallinger this in iOS6 but its not working in iOS5 After long search on google i am not able to find the solution so posted here. Please help with this problem.

I have also tried to subclassing the navigationcontroller and set the Rotate code it found here but no luck.


Solution

  • My sandbox app: https://github.com/comonitos/programatical_device_orientation

    The solution is easy:

    in interface (h file) :

        BOOL rotated;
    

    in implementation (m file): 1. rewrite

        -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
        {
        return rotated;
        }
    

    2 call [self setup]

        -(void) setup { 
        rotated = YES; 
        [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft]; 
        rotated = NO; 
        }