Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

straber

macrumors member
Original poster
Jul 3, 2012
60
0
I know this question has already been asked a bazillion times, but none of the solutions I've found so far have worked. Here's the situation, I have an app in which every view supports only portrait mode except for a subclass of MPMoviePlayerViewController which supports landscape left and right as well. This view is being presented modally from within a UINavigationController, so I have subclassed UINavigationController as well and that subclass supports landscape as well. I have made sure that the project file is set up to support all orientations except upside down. The code in my movie player subclass for rotation is this:

Code:
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (BOOL)shouldAutorotate {
    return YES;
}

This works fine in iOS 5.x, but it won't ever leave portrait mode in iOS 6. Does anyone have any ideas about what else I can do make the movie rotate in iOS 6?

Thanks
 
Last edited:
Why did you feel it necessary to subclass MPMoviePlayerViewController and UINavigationController? Also, which method are you using to present your modal view?
 
Well after doing exhaustive google searches for an answer, I saw some posts from people saying that it solved their problem to subclass those and explicitly say what orientations they support. I tried it both with and without subclassing them and it made no difference for me, I only mentioned it to let everyone know that I had already tried this.

I'm presenting the movie player using:

presentMoviePlayerViewControllerAnimated:
 
Assuming you're dealing with an iOS 6+ app, here's what I got to work in a test project:
  1. At the project-level (i.e. in the Summary tab), set the Supported Interface Orientations so that Portrait, Landscape Left, and Landscape Right are selected.
  2. Subclass UINavigationController and override the supportedInterfaceOrientations method so that it only returns UIInterfaceOrientationMaskPortrait.
  3. Replace your previous UINavigationController with your new subclassed one.
  4. That's it. You're done!

Because the default supported orientations for MPMoviePlayerViewController are "all but upside down", it will rotate as desired.
 
OK, first off, thanks for your help, Dejo! In my case, the problem ended up being that one of my co-workers had added the method:

Code:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return UIInterfaceOrientationMaskPortrait;
}

to the app delegate. I'm not sure why he did this, but the important thing for anyone else with this problem to note is that adding this to your app delegate overrides the orientations you've selected in the summary tab of the project file.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.