2

네비게이션 컨트롤러의 루트보기 컨트롤러는 세로 방향 만 지원하고 다른 컨트롤러는 모든 방향을 지원합니다. 이제 루트보기 컨트롤러에 있고 장치는 가로 방향으로 모든 방향을 지원하므로 가로로 열어야하는 세로로 열리는 다음보기 컨트롤러를 밀어 넣으면됩니다.하나의보기 컨트롤러에서 힘의 세로가 처음에는 세로로 표시됩니다.

도와주세요. 이의 ViewController을로드 할 때 처음 장치 oriantation을 확인

-(void)viewWillAppear:(BOOL)animated 
    { 
     [self willRotateToOrientation:[[UIDevice currentDevice] orientation]]; 
     [super viewWillAppear:YES]; 
    } 


- (void)willRotateToOrientation:(UIInterfaceOrientation)newOrientation { 
     if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) 
     { 
      if (newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight) { 

       //set your landscap View Frame 
       [self supportedInterfaceOrientations]; 

      } 



     } 
     else if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)) 
     { 
      if(newOrientation == UIInterfaceOrientationPortrait || newOrientation == UIInterfaceOrientationPortraitUpsideDown){ 
     //set your Potrait View Frame 
       [self supportedInterfaceOrientations]; 

      } 
     } 
     // Handle rotation 
    } 

SOR과 - 아이폰 4S iOS6.1.3

당신이 울부 짖는 코드를 사용하여의 ViewController 로그인 후 첫 화면에서 장치의 방향을 확인할 수 있습니다
+0

기기 회전을 계속하면 회전하나요? 또는 그것은 초상화에 남아 있습니까? – jcesarmobile

+0

@ jcesar : 기기를 회전하면 회전합니다. – Nilesh

답변

1

를 사용

관련 프레임을로드하십시오.

+0

답장을 보내 주셔서 감사합니다. 저는 똑같은 일을하고 있지만 도움이되지 않습니다. 어쨌든 나는 다른 사람들에게 도움이 될 수있는 답변을 upvoting 오전. – Nilesh

0

이것이 iOS6의 방향 변경과 관련된 문제라고 생각합니다. 당신은 UINavigationController

확인 this

0

1을 서브 클래스해야합니다. UINavigationController의 하위 클래스를 만들어야합니다. 다음의 메소드를 추가합니다. 하나의 불린 변수를 취하여 모든 방향을 지원하는지 여부를 확인하고 값을 변경합니다.

@implementation NavigationControllerViewController 

- (BOOL)shouldAutorotate 
{ 
return YES; 
}  

- (NSUInteger)supportedInterfaceOrientations 
{ 
AppDelegate *appdelgate=[[UIApplication sharedApplication]delegate]; 

if (appdelgate.issuppoertAll) { 
    // for iPhone, you could also return UIInterfaceOrientationMaskAllButUpsideDown 
    return UIInterfaceOrientationMaskAll; 

} 
return UIInterfaceOrientationMaskPortrait; 

    } 
@end 

2 당신은 당신이 강제로 세로

 obj_viewcontroller  = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 
    [self presentModalViewController:obj_viewcontroller animated:NO]; 
    [self dismissModalViewControllerAnimated:NO]; 

    [self.navigationController pushViewController:obj_viewcontroller animated:NO]; 

에 자사의 orientation.ie lanscape 공중을 변경하려면 다른 뷰 컨트롤러

사용이 코드에 폼 루트 뷰 컨트롤러를 탐색 할 때 3 두 번째보기 컨트롤러에서 부울 변수 값을 변경해야합니다.

-(void)viewWillAppear:(BOOL)animated 
{ 
appdelgate.issuppoertAll=YES; 
    } 

이 방법을 모든보기 컨트롤러에 추가하고 필요에 따라 방향을 설정하십시오.

- (NSInteger)supportedInterfaceOrientations 
{ 
return UIInterfaceOrientationMaskPortrait; 
} 
+0

나는 이것을 시도하고있다, 유망 해 보인다. – Nilesh