2012-10-22 4 views
6

私のアプリケーションでサポートされているインターフェイスの向きは縦向きと逆さまです。しかし、ビデオが再生されるとき、私はフルスクリーンの風景を再生したい。MPMovieViewControllerでポートレートのみのアプリケーションでランドスケープビデオを再生する方法

[player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen]; 
player.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 
[self presentMoviePlayerViewControllerAnimated:player]; 

どのように私は風景モードにそれを強制することができます。現在、このコードで、それだけで、デバイスを回転させても、肖像画を果たしていますか?ここで

+0

、この答えは優れている: http://stackoverflow.com/questions/12577879/shouldautorotatetointerfaceorientation-is-not-working-in-ios-6 – fpauer

答えて

11

は、私はそれを行う方法です:
プロジェクトファイルに 、あなたはまだのみポートレートである必要があり、あなたのViewControllersのすべてに今すぐ風景向きに supported interface orientations
をサポートしていることを確認し、このコード

//ios6 
- (BOOL)shouldAutorotate { 
    return NO; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationPortrait; 
} 
- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
} 

//ios4 and ios5 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
を追加します

iOS5とiOS6の両方の呼び出しを入れて、両方でコードを実行できるようにしました。

MPMoviePlayerControllerビューがフルスクリーンになると、ほかのすべてのレイヤーの上に新しいViewControllerが重ねて表示されます。したがって、サポートされているプロジェクトのインターフェイス指向に従って回転させることができます。他のViewControllerをどこに強制的にポートレートにするかはわかりません。

iOS6のために
+1

I場合おかげで、私はこれに頼るだろうすべてのビューコントローラにオリエンテーションコードを置く必要なしにそれを行う方法があることが期待されています(たくさんあります)。 – soleil

+0

私が行うのは、これらのメソッドだけを持つUIViewControllerを作成することです。それから、UIViewControllerを継承するのではなく、ポートレイトにする必要のあるすべてのUIViewControllerを継承します。 '.h'ファイルの' @ interface'行には、UIViewControllerの代わりにMyPortraitViewControllerという名前を付けました。 – Walter

+0

@soleil、私の理解では、残念ながら、これを行う唯一の方法です...理由は、** supportedInterfaceOrientations **セクションの下の 'UIViewController'に関するアップルのドキュメントにあります:'システムがビューコントローラのサポートされている向き –

関連する問題