Search code examples
iphoneobjective-cios7rotationmpmovieplayercontroller

Disable Rotation in a specific View Controller when Project settings allows all rotation


A Question was asked earlier. And i was facing the same issue where the Movie player was not rotating as the project properties didn't allowed to rotate. This issue was only faced in iOS7 over iPhone so i am trying another work around where i enable all the orientation in project Properties but the issue is that when ever i disable the rotation in other view controllers through functions like this

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
     return FALSE;
}

// Tell the system what we support
-(NSUInteger)supportedInterfaceOrientations
 {
return UIInterfaceOrientationPortrait;
}

- (BOOL) shouldAutorotate {
return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;

}

The view controllers still rotate which i suppose that this is because its allowed in project properties.

So the Question is..

How can i disable Rotation in a specific Media Player View Controller when Project settings allows all rotation?

OR

How can i Override rotation in a specific Media Player view controller over project properties (Disabling rotation) which doesn't work in iOS7


Solution

  • you can implement below method in you AppDelegate class it's working for me:

     - (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    
        if ([[window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]])
        {
            return UIInterfaceOrientationMaskAllButUpsideDown;
        }
        else
        {
            return UIInterfaceOrientationMaskPortrait;
        }
    }