0

我花了2小時找到正確的代碼來修復我的方向問題 這是我的電影播放器​​代碼。我需要將這個特定的視圖呈現在風景中。如何爲IOS6中的MPMoviePlayerController提供只有一個景觀的視圖

在appdelegate我設置所有的方向,並在我的rootviewcontroller我設置爲只有肖像和在我的movieplayer視圖爲風景,但不是運氣。有誰能給我一些關於如何解決問題的評論嗎?

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

我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; 
} 
+0

那麼...任何更新? – TonyMkenu 2013-05-17 13:08:25

回答

2

您可以檢查我的例子... https://dl.dropboxusercontent.com/u/19438780/testRotate.zip

我有2個控制器,導航控制器 - 肖像;對於這個我「subclassed」導航控制器(這裏是「肖像旋轉」代碼)

第3個控制器是風景 - 必須呈現模態,如果你想旋轉它 - 相應的旋轉代碼。

+0

嗨@tonyMkenu,我試了一下,但它不適合我的情況,讓我把代碼發佈一段時間 – Desmond 2013-05-20 09:05:39

1

我會去了解一下preferredInterfaceOrientationForPresentation,我在幾個月前花了約一個星期這個問題。我不記得確切我如何解決它,但我知道它有一些東西需要與實施該方法

相關問題