私は同じような状況があったが、私はiOSの6とからNavControllerベースのプロジェクトを使用しています。興味深いのは、私が回転させたくないMPMoviePlayerControllerをホストしているViewControllerですが、その中のビデオを回転させたいと思っていました。
デバイスの向きに基づいて、必要に応じて私は手動でMPMoviePlayerControllerを回転させます。 _videoViewは、ViewControllerのMPMoviePlayerControllerプロパティです。この例では、このビデオをYouTubeにアップロードする予定のため、希望の幅と高さを16×9のアスペクト比にハードコードしました。
- (void)updateVideoRotationForCurrentRotationWithAnimation:(bool)animation
{
CGSize containerSize = _videoView.frame.size; // Container NOT rotated!
float videoWidth = 384; // Keep 16x9 aspect ratio
float videoHeight = 216;
if(animation)
{
[UIView beginAnimations:@"swing" context:nil];
[UIView setAnimationDuration:0.25];
}
switch(self.interfaceOrientation)
{
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
m_videoPlayer.view.transform = CGAffineTransformMakeRotation(radians(90));
// This video player is rotated so flip width and height, but the container view
// isn't rotated!
[m_videoPlayer.view setFrame:CGRectMake((containerSize.width-videoHeight)/2,
(containerSize.height-videoWidth)/2,
videoHeight,
videoWidth)];
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
m_videoPlayer.view.transform = CGAffineTransformMakeRotation(radians(0));
// This video player isn't rotated
[m_videoPlayer.view setFrame:CGRectMake((containerSize.width-videoWidth)/2,
(containerSize.height-videoHeight)/2,
videoWidth,
videoHeight)];
break;
}
if(animation)
[UIView commitAnimations];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[self updateVideoRotationForCurrentRotationWithAnimation:YES];
}
私もそれが正しい初期配向しているので、表示されたビュー後updateVideoRotationForCurrentRotationWithAnimationを呼び出します。
これはIOS 6では廃止されており、実際にはプレーヤーは回転しません。 –
これは私のために働いていない - 私は映画を提示するビューコントローラを持って、その風景モードでは、完全には、映画はまだ肖像画で起動...アイデア? –