iOS 3.2 以降、MPMoviePlayerController クラスにより、ムービーをビュー階層に埋め込むことができます。今、私はこの問題に直面しています: MPMoviePlayerController のインスタンスを配置して縦向きのビューを作成します。ユーザーが「フルスクリーン」ボタンをタッチすると、このビューはフルスクリーン モードに入りますが、ビューは縦向きのままです。ユーザーがデバイスを回転させても、アプリが横向きのインターフェイスの向きを禁止しているため、フルスクリーンのムービー ビューは自動回転しません。そのため、ムービー プレーヤーのフルスクリーン ビューの自動回転を可能にするために、ビュー コントローラーの shouldAutorotateToInterfaceOrientation: メソッドを変更して、ムービー プレーヤーがフル スクリーン モードの場合に限り、ランドスケープに対して YES を返すようにしました。これは完全に機能します。ユーザーが全画面表示になってから横向きに回転すると、プレーヤーは自動的に横向きに回転し、画面全体に表示されます。
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
if(UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
return(YES);
}
if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
return([movieController isFullscreen]);
}
return(NO);
}
横向きのまま全画面表示で「完了」ボタンを押すと、問題が発生します。全画面表示が閉じて、元のビューが自動回転します。しかし、この自動回転は必要ありません。
部分的ではあるが受け入れられない解決策は、「MPMoviePlayerDidExitFullscreenNotification」をリッスンし、インターフェイスが横向きに回転している場合は、文書化されていない非公開関数を使用するよう強制的に向きを変えることです。
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait]
これは機能しますが、このメソッドの使用が禁止されているため受け入れられません。
を使用して方向を強制しようとしまし[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]
たが、タブバーにいるため、これは機能しません (UITabBar は横長のままです)。
ご協力いただきありがとうございます