2012-04-25 9 views
1

おはようございます! 私はPortaitオリエンテーションでアプリケーションを開発しています。アプリの残りの部分を混乱させることなく1つのビューの向きを残して残しておく方法があれば、私はさまよっていました。強制的なインターフェイスの向きアプリケーションの残りの部分がポートレートモードの場合、viewController上の風景

は私がまた...

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

が、運と... IBでビューコントローラの向きが横に設定されているが、私はアプリを実行すると、それがポートレートモードに登場し続ける

を返してみました運と

[[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO]; 

を設定しようとした...

すべてのヘルプは大歓迎されます。

ありがとうございます。

+0

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];それは警告を与えるが、それは動作します – Narayana

答えて

2

を唯一のものは、私のViewControllerで

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

を使用してpresentModalViewControllerでそれを提示しました。 これにより、ビューは強制的にランドスケープに維持されます。

+0

ニースワン!ありがとう...唯一の問題は、それがNavigationControllerの中に置いておくことが良いことです...それは不可能かもしれません...もう一度ありがとう! –

+0

ニース!どうもありがとうございました !メソッド 'shouldAutorotate'はどういう意味ですか? – why

3

ビューの回転を手動で設定することができます。例えば、90度回転させる:私のために働いた

view.transform = CGAffineTransformMakeRotation(M_PI/2); 
1
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; 

あなたのイベントで書き込みます。

+0

これは私のプロジェクトで働いていた.... –

関連する問題