0
votes

My app supports only Landscape. I've added an MPMoviePlayerController to the view of my view controller.

When I press full screen button, it works fine and it will rotate in Landscape only for iOS versions prior to iOS 5. However, in iOS 5.0+, it also supports portrait (only when I enter into full screen mode).

How can I prevent portrait support in iOS 5.0 and above?

2

2 Answers

0
votes

Try subclassing MPMoviePlayerViewController and overriding the shouldAutorotatoToInterfaceOrientation method to only support landscape modes:

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    if((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
    {
        return true;
    }
    else
    {
        return false;
    }    
}
0
votes

I resolved this problem thus: create custom navigation controller what support 2 orientation: UIInterfaceOrientationLandscapeLeft && UIInterfaceOrientationLandscapeRight

More details: 1. Create custom navigation controller

CustomNavigationController.h file

#import <UIKit/UIKit.h>

@interface CustomNavigationController : UINavigationController

-(CustomNavigationController*)initWithRootViewController:(UIViewController *)rootViewController;

@end

CustomNavigationController.m file

@implementation IORNavigationController

-(CustomNavigationController*)initWithRootViewController:(UIViewController *)rootViewController
{
    self = [super initWithRootViewController:rootViewController];

    if (self)
    {
    }

    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
}


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


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

@end

2.In Appdelegate add self navigation controller

Appdelegate.h

@property (nonatomic, retain) CustomNavigationController*  navigationController;

Appdelegate.m

self.navigationController = [[[CustomNavigationController alloc] initWithRootViewController:start] autorelease];

self.navigationController.view.autoresizesSubviews = YES;

window.rootViewController = self.navigationController;
    [self.navigationController setNavigationBarHidden:YES];

And now you have app with two orientation and video in landscape orientation.