1

私はUITabBar5つのタブを持つベースのiOSアプリケーションを持っています、これらのタブのいくつかはUINavigationControllerです。一部のタブビューは横向きをサポートしていますが、他のタブビューはサポートしていません。

ビュー自体のすべての自動回転を処理しましたが、アプリをテストしているときに何か奇妙なことが起こっていることに気付きました。新しいタブが選択されるたびに、shouldAutoRotateToInterfaceOrientationメソッドは誰からも呼び出されませんUIViewController。新しいタブを選択するときに方向チェックを強制する方法はありますか?

4

5 に答える 5

1

メソッドを作成し、それを呼び出してviewWillAppear向きを確認し、必要に応じて強制します。

于 2012-08-09T23:12:26.693 に答える
0

Apple UIViewController Programming Guide for iOS には次のように記載されています。

「タブ バー コントローラーは、管理されているすべてのビュー コントローラーが新しい方向をサポートしている場合にのみ、方向の変更を許可します。」

ランドスケープをサポートしたい場合は、すべてのタブがサポートされていることを確認する必要があります。

于 2012-08-14T15:11:38.747 に答える
0

通常、これが表示されるのは、タブバーのビューコントローラーの 1 つがshouldAutoRotateToInterfaceOrientation適切に設定されていないためです。タブバーに追加されたすべてのクラスは、同じ値を設定する必要があります。そうしないと、ローテーションがうまくいきません。

于 2012-08-10T00:36:05.320 に答える
0

方法shouldAutorotateToInterfaceOrientation:NOT supported in iOS 6. 非推奨です。あなたがココアでの作業を始めたばかりの初心者で、iOS 6 ではビュー コントローラーがめちゃくちゃで、iOS 5 では完全である理由を疑問に思っている場合に備えて、shouldAutorotateToInterfaceOrientation: はもうサポートされていないことを知っておいてください。それはそれでうまくいくかもしれませんXcode 4 to 4.3NOT work on Xcode 4.5.

Apple は、これをよりクリーンな方法で行うための新しい方法を提供しています。代わりに supportedInterfaceOrientations を使用してください。ビューコントローラーがサポートするすべてのインターフェイスの向き、インターフェイスの向きの値のマスクを返します。

UIInterfaceOrientationMask Enum:

これらの定数は、View Controller がサポートするインターフェイスの向きを指定するためのマスク ビットです。

    typedef enum {
     UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
     UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
     UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
     UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
     UIInterfaceOrientationMaskLandscape =
     (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
     UIInterfaceOrientationMaskAll =
     (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
     UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
     UIInterfaceOrientationMaskAllButUpsideDown =
     (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
     UIInterfaceOrientationMaskLandscapeRight),
 } UIInterfaceOrientationMask;
于 2012-08-14T12:59:40.150 に答える
0

iOS 6.0以降を使用している可能性があります。iOS 6.0以降と同様に、shouldAutoRotateToInterfaceOrientationメソッドは廃止され、このために呼び出されません。UINavigationControllerとUITabbarContlllerの両方に独自のカテゴリを作成し、デバイスが回転したときに呼び出されるメソッドを追加する必要があります。

于 2013-02-20T08:44:14.113 に答える