4

デバイス自体が回転しているときにアプリケーションでインターフェースを回転させようとしていますが、うまくいきません。サポートされているインターフェイスを plist 情報ファイルに追加し、shouldRotateToInterfaceOrientation に対して yes を返しました。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {  
    if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {  
        はいを返します。  
    } そうしないと {  
        いいえを返します。  
    }  
}

これがローテーションの実装方法ですか?
助けてください!

4

4 に答える 4

1

info.plist を編集して、サポートされている向きをそこに追加してみてください。

プロジェクトを選択 --> ターゲットを選択 --> 情報 --> サポートされているインターフェイスの向きを選択し、プラス記号を 4 回クリックしてこれらの向きをサポートします。

Item 0   Landscape (left home button)
Item 1   Landscape (right home button)
Item 2   Portrait (top home button)
Item 3   Portrait (bottom home button)

それが役に立てば幸い!

于 2012-06-19T12:55:48.680 に答える
0

shouldRotateToInterfaceOrientationさまざまな方向をサポートするビューコントローラに追加したことを確認してください。アプリデリゲートには入りません。

于 2011-01-04T23:43:52.273 に答える
0

標準の UI 要素を使用している場合、向きをサポートするのは簡単です。その場合は正しい方向に進んでいます。

UITabController を使用している場合、すべてのビューが同じ向きをサポートする必要があります。そうでない場合は、デフォルトで最小 (Portrait など) になると思います。

また、ビューに NIB を使用している場合は、Interface Builder でビューを構成するときに「サブビューの自動サイズ変更」がチェックされていることを確認してください。

于 2011-01-04T23:57:07.347 に答える
0

を使用している場合はUITabBarController、それをサブビューと呼ぶ必要がありますshouldAutoratateToInterfaceOrientation

shouldAutorotateToInterfaceOrientation2 つのタブがUITabViewControllerあるとします。.

[[tabBarController.viewControllers objectAtIndex:0] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
[[tabBarController.viewControllers objectAtIndex:1] shouldAutorotateToInterfaceOrientation:interfaceOrientation];

もちろん、「tabBarController」は、UITabBarControllerIB を介して XIB ファイルにリンクする必要があります。

ありがとう、

于 2011-05-30T04:17:52.443 に答える