0

xcode4.5.1のマスター/詳細テンプレートを使用してユニバーサルアプリを作成しています。iPadで横向きを保つために、私は以下の設定をしています。iOS6で動作しますが、iOS5では常に縦向きを保ちます。どうすれば問題を解決できますか?(プロジェクトのリンク:https ://www.dropbox.com/s/7wm9l8kxhan6kp1/itstest.zip )</ p>

  1. plist

    <key>UISupportedInterfaceOrientations~ipad</key>
    
    <array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
    
    </array>
    
    <key>UISupportedInterfaceOrientations~iphone</key>
    
    <array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
    
    </array>
    
  2. Appdelegate.mに以下を追加することもできます

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

ありがとう!

4

1 に答える 1

1

このメソッドshouldAutorotateToInterfaceOrientationは、AppDelegateでは呼び出されず、View Controller(ドキュメント)でのみ呼び出されます。次のコードをViewController内に配置します(ただし、特定のプロジェクトでは、内部にのみ配置するだけで十分だと思いますMasterViewController)。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    else
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
于 2012-12-31T02:43:15.680 に答える