【问题标题】:iPhone Movie Rotation For Only SubviewiPhone电影旋转仅用于子视图
【发布时间】:2011-06-24 14:23:01
【问题描述】:

我正在开发一个除非正在播放电影,否则不允许旋转的应用。我的应用旋转得很好,但是当我尝试观看电影时出现了问题。

模拟器被强制旋转,但电影没有。下面是一个例子:

我也不知道如何旋转电影。我希望只旋转子视图。我的代码如下:

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:finalURL]];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {  
                // Use the 3.2 style API  
                moviePlayer.controlStyle = MPMovieControlStyleDefault;  
                moviePlayer.shouldAutoplay = YES;  
                [self.view addSubview:moviePlayer.view];  
                [moviePlayer setFullscreen:YES animated:YES];
             [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];

             // Rotate the view for landscape playback
             [[moviePlayer view] setBounds:CGRectMake(0, 0, 480, 320)];
             [[moviePlayer view] setCenter:CGPointMake(160, 240)];
             [[moviePlayer view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)]; 

             // Set frame of movieplayer
             [[moviePlayer view] setFrame:CGRectMake(0, 0, 480, 320)];  

            } else {  
                // Use the 2.0 style API  
                moviePlayer.movieControlMode = MPMovieControlModeHidden;  
                [moviePlayer play];  
            } 
}

编辑:我尝试了[moviePlayer setOrientation UIInterfaceOrientationLandscapeRight];,但编译器给了我一个错误,没有任何反应

【问题讨论】:

  • 你在真机上测试过吗?
  • 是的,它做同样的事情。

标签: iphone objective-c xcode rotation mpmovieplayercontroller


【解决方案1】:

你在使用MPMoviePlayerController吗?

试试MPMoviePlayerViewController。该类是一个 UIViewController,应该自己处理它的旋转。

你只需调用[moviePlayerViewController moviePlayer];方法就可以从视图控制器获取MPMoviePlayerController

【讨论】:

  • 我是,我只是忘了将它添加到问题中。它现在就在那里。
猜你喜欢
  • 1970-01-01
  • 2011-05-18
  • 1970-01-01
  • 1970-01-01
  • 2012-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多