2012-06-14 5 views
0

메소드를 호출 할 때보기를 강제로 원할하게하고 싶습니다. 내 방법이 실행되면IOS -보기를 가로 방향으로 강제하는 방법

내가 전화 :

[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)UIInterfaceOrientationLandscapeRight]; 

방법이

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

문제는 뷰가 회전을 강요하지 않는다는 것입니다 자동 회전 할 수 있습니다. 시뮬레이터에서 테스트하거나 실제 장치에서 작동 할 수 있습니까?

답변

1
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES]; 
+0

많은 사람이 Thaks! 니가 끝냈어! = D – 88fsantos

+0

하나의 문제가 있습니다. 내가 만든 내부의보기는 가로로 설정되어 있지 않습니다. S 이제 너비가 480이고 높이가 320입니다. 맞습니까? 하지만 그렇지 않습니다 : S – 88fsantos

+1

상대 크기로보기를 만들어야하는 것처럼 들립니다. 따라서'initWithFrame : CGRectMake (0, 0, 320, 480)]'로 뷰를 생성하는 대신'initWithFrame : CGRectMake (0, 0, [UIScreen mainScreen] .bounds.size.width, [UIScreen mainScreen] .bounds.size.height])' – Anthony

관련 문제