MPMoviePlayerController rotating in full screen wh

2020-02-08 08:22发布

this question is only one part of my problem. I am implementing iOS6 rotation and orientation support for my existing application.

So I have a ViewController that contains a MPMoviePlayerController embedded in ViewController view ( my application requires it ). User can play the video and see it in the embedded view or click on full screen button using the default player controls and player goes to full screen mode.

Now I have restricted the view controller to only support portrait orientation using the new rotation APIs provided by iOS6.

// New Autorotation support.
- (BOOL)shouldAutorotate;
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

this works pretty well. the ViewController only supports portrait and user play the movie in embedded view.

Now the problem comes, when User goes into full screen mode. In full screen mode, the movie is keep on rotating, when i rotate the simulator/device. When i rotate the device while movie being played in full screen mode with breakpoints in shouldAutorotate and supportedInterfaceOrientations , it still comes in these both methods which return NO and UIInterfaceOrientationMaskPortrait respectively, but still the movie is rotating ...

Why is this happening? .... this is one part of my question ... the 2nd part is I want the movie to enter in landscape mode when the user goes to full-screen mode. and I want the movie player to lock in landscape mode until user presses the DONE button.

Please help ....

8条回答
走好不送
2楼-- · 2020-02-08 09:19

For iOS 6 you can use this answer.

But if you supports < iOS 6 need a different approach.

You must create custom navigation controller and to it add methods for creation with root controller and method for rotation.

It will look like: m file and h file.

And in your AppDelegate must call method for init:

In h file:

#import "IORNavigationController.h"

and

@property (nonatomic, retain) IORNavigationController*  navigationController;

In m file:

self.navigationController = [[[MyNavigationController alloc] initWithRootViewController:start] autorelease];
查看更多
走好不送
3楼-- · 2020-02-08 09:20

Just add this code to yours view controller

-(NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}
查看更多
登录 后发表回答