2010-12-30 16 views
2

ナビゲーションベースのアプリがあります。ルートビューで任意の行をクリックすると、次のビューが横向きモードになります。iphoneでデバイスの向きをプログラムで変更する

これを実装する適切な方法を見つけることができません。私が試みたのは:

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

しかし、これは動作しません。ビューは、ユーザが回転させるときではなく、横モードでのみ開く必要があります。誰でも私を助けることができます。おかげ

+0

は、iOS 6を使用していますか? – AppleDelegate

答えて

1

あなたがビューでマジックラインを使用して.......向きを変更するためにあなたのデバイスを強制することができますは、風景モードであなたの視野を設計してみ

[[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeRight]; 

すべてのベスト..

+1

あなたの答えをありがとう、それは働いたが、警告を表示します。私は私たちのプライベート関数を使用することはできませんと思う – iPhoneDev

+0

私は方法がサポートされていないかもしれないと思うが、なぜそれは動作しないと思う..... –

+0

setOrientationはUIDeviceのメソッドではない – Fidel

1

表示されますそして、それのビューコントローラでは、と横向き 用縦向きとYESため

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    ..... 
} 

リターンノーでこれがlandscaであなたのビューが表示されますpeモード。ここで

+0

私はこれを試しましたが、おそらくそのナビゲーションアプリケーションのため – iPhoneDev

0

は私の風景ビューベースのアプリケーションからいくつかのコードです:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ 

    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft){ 
     return YES; 
    } 
    else { 
     return NO; 
    } 

} 

それは風景モードでのみ表示され、景観を切り替えるには持っている風景ベースのViewControllerでこれを入れて左と風景右。また、あなたのxibが横長ベースである必要があります。

3

マイサンドボックスアプリ: https://github.com/comonitos/programatical_device_orientation

溶液は容易である:インターフェース(Hファイル)に

:実装(Mファイル)に

BOOL rotated; 

: 1リライト

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

2コール[セルフセットp]

-(void) setup { 
    rotated = YES; 
    [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft]; 
    rotated = NO; 
    } 
+0

あなたは素晴らしいです...あなたは私の問題の解決策を検索する無駄な時間を知っていません... http:// stackoverflow .com/questions/18654670/mpmovieplayercontroller-does-not-change-orientation-in-full-screen-mode-in-ios-5 .....あなたの答えとコードは、解決策を達成するための多くの方法を助けてくれました。 ...高齢者...+1 – Dilip

+0

))ありがとう。聞いてうれしい – comonitos

関連する問題