2012-03-06 13 views
0

私はアプリを手動で方向をロックしたように動作させたいと思います。私はアプリの向きをロックする方法を見つけようとしています。 Info.plistファイルでは、私は、この設定を持っている:iPadアプリ(plistまたはUIViewController?)で向きを固定する

Supported interface orientations (iPad) 
Item 0 Landscape (right home button) 
Item 1 Landscape (left home button) 

私は風景モードではなく縦向きに滞在から私のviewControllersを維持するのに十分だろうと思いました。しかし、それはしません。私がする必要があります

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

すべて私のviewControllersで?ありがとう!

答えて

0

すべてのビューコントローラでshouldAutorotateToInterfaceOrientationを実装することはできますが、これはおそらく達成しようとしていることを実行する最も速く、最も実際的な方法ではありません。

階層内のいずれかのビューコントローラが向きの変更に適合しない場合、iOSは回転を停止しようとします。つまり、ルートビューコントローラだけが、shouldAutorotateToInterfaceOrientationを横向きの向きで実装する必要があります。プッシュまたは追加された各View Controllerは、その機能に準拠します。

0

私はいくつかのアプリでこれを実行しなければならず、いくつかの理由から必要でした。

多くのテストが終わった後、我々は条件がinfo.plistとすべてのviewControllerに設定される必要があると判断しました。

これはplistに設定されていて、shouldAutorotateToInterfaceOrientationのすべてが許可された方向に対してのみyesを返すことを確認してください。

これはplistがLAUNCHの向きを許可するのに役立ちますが、その後は特にモーダル表示を使用するときにアプリが回転する可能性があるからです。

あなたは、iPad上で薄くなりをして、私の無料アプリの一つダウンロードすることができます:はいあなたはhttp://itunes.apple.com/mx/app/hoteles-city/id471505865?mt=8

0

を。

しかし私は別の解決策を持っています。すべてのUIViewControllerでは、私は以下を使用します:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft){ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
    } else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) { 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
    } else { 
     return NO; 
    } 
} 
関連する問題