iOS7 viewController和MPMoviePlayerViewController旋转

iOS7 viewController和MPMoviePlayerViewController旋转,ios,objective-c,uiviewcontroller,rotation,mpmoviewcontroller,Ios,Objective C,Uiviewcontroller,Rotation,Mpmoviewcontroller,我尝试了很多东西,但我仍然无法在我所有的应用程序中只旋转一个ViewController。 我想用mpmovieplayervicewcontroller只在vc中显示(或旋转) 喜欢Facebook应用程序中的视频。该应用程序仅为纵向,但视频可以旋转。 播放视频后,应用程序以纵向模式返回。 我可以旋转,但在“完成”videoplayer按钮单击后,以横向模式返回视图 我怎样才能解决这个问题 非常感谢。创建一个新的UIViewController,用于显示视频 创建MPMoviePlayerCo

我尝试了很多东西,但我仍然无法在我所有的应用程序中只旋转一个ViewController。 我想
mpmovieplayervicewcontroller
只在vc中显示(或旋转

喜欢Facebook应用程序中的视频。该应用程序仅为纵向,但视频可以旋转。 播放视频后,应用程序以纵向模式返回。 我可以旋转,但在“完成”videoplayer按钮单击后,以横向模式返回视图

我怎样才能解决这个问题


非常感谢。

创建一个新的
UIViewController
,用于显示视频

创建
MPMoviePlayerController
属性

@property (nonatomic, strong) MPMoviePlayerController* moviePlayerController;
然后在viewDidLoad中,尝试以下操作:

 - (void)viewDidLoad
    {
        [super viewDidLoad];

        _moviePlayerController = [[MPMoviePlayerController alloc] init];
        _moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;

        _moviePlayerController.contentURL = [NSURL URLWithString:@"example.com"];

        // Rotating the player to landscape position
        _moviePlayerController.view.frame = CGRectMake(0.0f,
                                            0.0f,
                                            [UIScreen mainScreen].bounds.size.height,
                                            [UIScreen mainScreen].bounds.size.width);

        _moviePlayerController.view.transform = CGAffineTransformMakeRotation(M_PI_2);
        _moviePlayerController.view.center = self.view.center;

        UIView *playerView = _moviePlayerController.view;


        [self.view insertSubview:playerView atIndex:0];
        [_moviePlayerController prepareToPlay];
    }
希望能有帮助

  • 创建用于播放视频的新视图控制器

  • 单击项目,然后单击目标。在“部署信息”下的“常规”类别中,启用所有轮换

  • 现在打开您的根视图控制器并放置以下行。给出应用程序的方向

  • 代码:


    4.现在,如果使用addsubview方法来表示其他ViewController的视图,则无需将Orition方法应用于其他控制器。但是,如果你使用了PresentController方法,那么请向该控制器添加方向方法

    参考此url:检查:这可能会有帮助。嗯,因此,如果我在HomeVC中有肖像,我可以使用
    [self-PerformsgueWithIdentifier:@“MyIdentificationEW”发件人:self]
    和set
    -(NSUInteger)支持的接口方向{return UIInterfaceOrientationMaskPortrait;}
    。但是,当我将有景观播放器,我必须做什么?谢谢这没什么问题,但一定要确保你在视频播放vc的地方设置了vc的定位方法。成功!!!它可以工作:D我在
    @interface myplayervewcontroller:mpmovieplayervewcontroller
    中的每个VC中添加
    支持的界面方向
    纵向。如果用户在播放器中按“完成”按钮,我以前的VC就会出现在人像中!!!!非常感谢+1和正确答案!谢谢,这对我有帮助,+1!但是我必须编辑一些导航栏和状态栏的代码才能得到一个好的结果。我将尝试其他解决方案,然后再标记为正确答案。谢谢
    -(BOOL)shouldAutorotate
    {
        return TRUE;
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        {
            return UIInterfaceOrientationMaskPortrait;
        }
        else
        {
            return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
        }
    }