1
votes

Entire app is supports only portrait orientation, only playing a video needs to support all the orientations. The application is running perfectly on iOS < 6.0 in entirely portrait mode, now as the requirement need to support auto-rotation orientation for the MPMoviePlayerViewController (video to play) for iOS 6.0 as well, I've searched many things around, and I got below solutions so I've applied those in my app,

1) Support all the orientations in plist or in targets

2) add the below orientation functions for portrait support

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

- (BOOL)shouldAutorotate
{
    return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

3) Override MPMoviePlayerViewController class, and added all suitable orientation methods to support.

4) Put below method in AppDelegate file, and return landscape if you find an object of MPMoviePlayerViewController.

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { }

but at last, there's no success! - I can't play video in landscape mode, only portrait is supporting in entire app.

I don't know why its not rotating? Is there something that I'm missing to set?

1

1 Answers

0
votes

I recently had to do the opposite in an app I developed, where I had to force video-playback to appear only in landscape mode. What I did was to let my app support all orientations, and instead override my mpMoviePlayerViews shouldAutorotateToInterfaceOrientation method to return YES only for landscape.

Since you want to do the opposite, how about allowing both potrait and landscape for your app - but limiting your regular views to only potrait? (and thus avoiding your problems to allow rotation for your mpmovieplayerview) I think it should be possible to create a parent (view) class that your regular views could inherit from, and in your parent class just override shouldAutorotateToInterfaceOrientation to only support/return YES for potrait mode.