如何在IOS6中为MPMoviePlayerController仅提供一个带有landscape的视图 [英] how to provide only one view with landscape for MPMoviePlayerController in IOS6

查看:69
本文介绍了如何在IOS6中为MPMoviePlayerController仅提供一个带有landscape的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了2个小时找到正确的代码来解决我的定位问题
这是我的电影播放器​​代码。我需要这个特定的视图以横向显示。

i had spend 2 hours finding the correct code to fix my orientation problem this are my movieplayer code. i need this particular view to be shown in landscape.

在appdelegate中我设置了所有方向,在我的rootviewcontroller中,我设置为仅肖像,在我的电影播放器​​视图中为横向但不是运气有人可以给我一些关于如何解决问题的评论吗?

in appdelegate i set all orientation and in my rootviewcontroller i set is as portrait only and in my movieplayer view as landscape but not luck. can anybody give me some comment on how to fix the issues please ?

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

我的rootviewcontroller

my rootviewcontroller

- (BOOL)shouldAutorotate
{
    return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}


-(void)prepareIntroVideo
{
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"designthinking_pt1" ofType:@"mp4"]];
    self.playercontroller = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [self.playercontroller.view setFrame:CGRectMake(0, -20, 320, 480)];
    self.playercontroller.movieSourceType = MPMovieSourceTypeFile;
    self.playercontroller.scalingMode = MPMovieScalingModeAspectFill;
    self.playercontroller.fullscreen = NO;
       self.playercontroller.controlStyle = MPMovieControlStyleFullscreen;
    //playercontroller.controlStyle = MPMovieControlStyleFullscreen;
    self.playercontroller.view.userInteractionEnabled =YES;
    self.playercontroller.view.backgroundColor = [UIColor blackColor];
    self.playercontroller.shouldAutoplay = NO;

    //playercontroller.repeatMode = YES;
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlaybackComplete:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:self.playercontroller];


    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(applicationDidEnterBackground)
                                                 name: UIApplicationDidEnterBackgroundNotification
                                               object:[UIApplication sharedApplication]];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(applicationWillEnterForeground)
                                                 name:UIApplicationWillEnterForegroundNotification
                                               object:[UIApplication sharedApplication]];


    [self.playercontroller prepareToPlay];
    [self.view addSubview:self.playercontroller.view];
    [self.playercontroller setFullscreen:YES animated:YES];


    //[self.playercontroller stop];
    [self.view sendSubviewToBack:self.playercontroller.view];

}

- (BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationLandscapeLeft;
}


推荐答案

您可以查看我的示例。 .. https://dl.dropboxusercontent.com/u/19438780/testRotate.zip

You can check my example... https://dl.dropboxusercontent.com/u/19438780/testRotate.zip

我有2个带导航控制器的控制器 - 肖像;对于这个我子类导航控制器(这里是肖像的旋转代码)

I have 2 controllers with navigation controller - portrait; for this I "subclassed" nav controller (here is the "rotation" code for portrait)

第3个控制器是风景 - 如果你想旋转它必须呈现模态 - 相应地放置旋转代码。

The 3th controller is landscape - must be presented modal if you want to rotate it - put the rotation code accordingly .

这篇关于如何在IOS6中为MPMoviePlayerController仅提供一个带有landscape的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆