0

私はMainWindow.xibにUITabBarControllerを持っています。UITabBarController内のビューの水平方向を強制する方法は?

各タブには、UITableViewControllerを持つUINavigationControllerが含まれています。

UITableViewControllerのボタンを押すと、ビューコントローラがナビゲーションスタックに水平方向にプッシュされます。

私のUITableViewController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations. 
    return YES; 
} 

に乗っオーバー以下を有するが押さビューコントローラ(XIBでは、風景のように定義される)は、水平方向に表示されません。

どのように水平方向に押し込むことができますか?

+0

このメソッドをオーバーライドしても自動回転が強制されません。 View Controllerでこれを実装する必要があるかどうかを確認するには、http://stackoverflow.com/questions/6492085/iphone-development-viewcontroller-portrait-to-landscape-no-autorotate/6492166#comment-7634401 – Saphrosit

答えて

1

オートローテーションは、いくつかの制約を持っている:UITabBarControllerのため

  1. を、オートローテーションはタブバーのサポートオートローテーションのコントローラのすべての場合に動作します。

  2. (UINavigationControllerの場合)、自動回転は、UINavigationControllerのrootViewControllerがサポートしている場合にのみ機能します。

あなたは、この条件が満たされていることを確実にしたら、あなたは試してみて、あなたのUITableViewControllerをプッシュすることができますが、このようにそのshouldAutorotateToInterfaceOrientationを定義した:

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

EDIT:

あなたUIViewControllersのすべてべきshouldAutorotateToInterfaceOrientationについてのこの定義を有する:

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

は、上記の定義を持つはずの風景を除きたいものを除きます。

また、UITabBarControllerのshouldAutorotateToInterfaceOrientationを正しく実装するために、this threadの最後の投稿を見てください。

+0

私のUITabBarControllerはMainWindow.xibの一部であるため、AppDelegateで定義されています。 UITabbarControllerには、UITableViewControllerを含むUINavigationControllerが含まれています。私はVCのすべてでshouldAutoRotateを実装しましたが、まだ運がありません。 –

+0

質問、あなたの風景ビューを押すことを離れて:デバイスを回転させると、ビューは自動回転しますか?そうでない場合は、コード内の何かをチェックする必要があります。具体的には、MainWindows UITabBarControllerも 'shouldAutorotateToInterfaceOrientation'を定義する必要があります。 – sergio

+0

デバイスを回転させると、自動回転しません。私はあなたのメソッドを私のappdelegateに追加しました(これはUITabBarControllerが接続されている場所です)。運がない。 –

0

あなたはあなたのアプローチは理にかなっても、この方法でのみ横向きを返す

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations. 
    return (UIInterfaceOrientationLandscapeRight or UIInterfaceOrientationLandscapeLeft); 
} 
+0

を確認してください。 –

+0

あなたは異なる向きにしたいものです。viewController1でviewContoller1を実行してから、viewController1にコードを適用したいのですが、 –

+0

私はそれを試みましたが、残念なことに動作しません。 VC1はVC3をプッシュするVC2をプッシュします(私はこれをランドスケープにします)。すべて私はあなたのコードを実装する必要があります。 –

0

などviewWillAppearメソッドのステータスバーの向きを変更し、viewWillDisappearに戻す必要があります。しかし、あなただけの風景になりたいプッシュビューコントローラでこれを試しました:

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

をこの方法の考え方は、ビューコントローラのサポートの方向にYESを返すことです。 UITabBarControllerUINavigationControllerため

+0

は動作しません。それはまだポートレートで表示されます。 –

関連する問題