6

このコードを使用して、ユーザーがビデオの視聴を終了したときに向きを強制的に縦に戻しました (これにより、横向きモードでの表示が可能になります)。その後、ビデオ ビュー コントローラーをナビゲーション コントローラーから外します。

//set statusbar to the desired rotation position
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];

//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

これは まで完全に機能しましたiOS 5.1.1。別の投稿を読んだ後、新しい present/dismiss メソッドを使用しようとしましたが、それらは今すぐ使用する必要があります。

[self presentViewController:mVC animated:NO completion:NULL];
[self dismissViewControllerAnimated:NO completion:NULL];

問題は、それがまったく機能しないことです。ビデオ ビューアーを横向きに回転させてからポップすると、設定ビュー (テーブル ビュー コントローラー) が戻ってきますが、横向きモードでも表示されます。

ここからのヒントも試しました

「このsetStatusBarOrientation:animated:メソッドは完全に廃止されたわけではありません。ただしsupportedInterfaceOrientations、最上位のフル スクリーン ビュー コントローラのメソッドが 0 を返す場合にのみ機能します。これにより、ステータス バーの向きが一貫していることを確認する責任が発信者の手に委ねられます。」

supportedInterfaceOrientationsそのため、(上記の最初のコード ブロックを呼び出す前に) 強制するフラグを設定して実験しましたreturn 0が、どちらも機能しません。

誰かがこれに対する解決策を持っていますか? お時間とご尽力いただきありがとうございます。

4

3 に答える 3

17

setStatusBarOrientationメソッドの動作が少し変わりました。Appleのドキュメントによると:

setStatusBarOrientation:animated: メソッドは完全に廃止されたわけではありません。最上位のフルスクリーン ビュー コントローラーの supportedInterfaceOrientations メソッドが 0 を返す場合にのみ機能するようになりました。

于 2012-09-26T19:52:08.390 に答える
2

Your root view controller should answer false to the method shouldAutorotate in order that your app responds to setStatusBarOrientation:animated

From Apple Documentation: "if your application has rotatable window content, however, you should not arbitrarily set status-bar orientation using this method"

To understand that, put a breakpoint in the shouldAutorotate method and you will see that it is called juste after setting the status bar orientation.

于 2012-09-25T15:17:27.017 に答える
0

これが私が修正した方法です。

https://stackoverflow.com/a/14530123/1901733

現在の質問は、上記の URL からの質問にリンクされています。

statusBarOrientation は ios6 の実際の問題です。

于 2013-01-25T20:53:41.780 に答える