0

私のアプリケーションは非常に単純ですが、起動時にいくつか問題があります。Info.plist をランドスケープするように設定しましたが、順序を無視しているようです。実際、アプリが読み込まれているとき、シミュレーターは横向きになりますが、その後縦向きモードに戻ります。

これは、ビューとコントローラーの階層です。

  • MainViewController (単に shouldAutorotateToInterfaceOrientation をオーバーライドするために UITabBarController を拡張します:)
    • タブとして 3 つの拡張された UITableViewControllers (これらにも shouldAutorotateToInterfaceOrientation が正しく設定されています)。

デバイスの向きを強制的に横向きにすると、次のようになります。

[[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight];

次に、シミュレーターが縦向きモードで一瞬点滅し、次に横向きになります。問題は、この方法で自動回転アニメーションが開始されることです。これは私が許容できないことです。固定された、景観の良いアプリケーションが欲しいだけです。

手がかりはありますか?何か不足していますか?

4

2 に答える 2

0

以下を試してください。うまくいかない理由がわからない

1)
.plist ファイルでキー UIInterfaceOrientation を UIInterfaceOrientationLandscapeRight に設定します

2) UITabBarController shouldAutorotateToInterfaceOrientation() メソッドをオーバーライドします。次のコードは、タブ 0 と 1、および 1 つのコントローラーのみを扱います。ナビゲーション コントローラーがあり、スタック上にある可能性のあるさまざまなコントローラーを制御したい場合は、それに応じてコードを変更する必要があります。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    BOOL tabZeroController = [[[self.viewControllers objectAtIndex:0] visibleViewController] isKindOfClass:[YourTabZeroTableViewController class]];

    BOOL tabOneController = [[[self.viewControllers objectAtIndex:1] visibleViewController] isKindOfClass:[YourTabOneTableViewController class]];


    if(self.selectedIndex == 0 && tabZeroController)
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

    if(self.selectedIndex == 1 && tabOneController)
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

    return NO;

}

2) 設定

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

デリゲートの applicationDidFinishLaunching() メソッドでは、デバイスではなく、シミュレーターにのみ必要です

3) コントローラーに次の shouldAutorotateToInterfaceOrientation(method) を追加します

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
   return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

4) デバイスでアプリを実行し、[ハードウェア] メニュー項目の [左に回転] と [右に回転] を使用して、正しく動作することを確認します。横向きモードでディスプレイが表示されるはずです。

于 2009-07-17T08:11:35.850 に答える
0

多分これは http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.htmlを助けることができます

于 2010-03-24T15:02:01.433 に答える