1

2 개의 뷰 컨트롤러, 루트 및 세부 정보가 있습니다. 루트보기 컨트롤러는 가로 및 세로 방향을 지원하므로 다음 코드가 있습니다.pushViewController : - 장치가 가로 모드 일 때 세로 모드 전용 모드로 표시하는 방법?

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

위 코드는 루트보기 컨트롤러에서 완벽하게 작동합니다.

루트보기 컨트롤러가 표시되고 사용자가 장치를 가로 모드로 돌리면보기가 그에 따라 조정됩니다. 이 시점에서 내 세부보기 컨트롤러를 스택으로 밀어 넣으면 가로 모드로로드됩니다. 그러나, 그것은 세로 모드 만 지원하도록 구성 되었기 때문에 안됩니다. 내 상세 뷰 컨트롤러에 아래의 코드를 사용하고 있습니다 :

두 번째 뷰 컨트롤러에서
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

답변

0

은 당신의 코드를 대체 ... 같은 코드를 실행 끝 단지 매크로의

return UIInterfaceOrientationIsPortrait(interfaceOrientation); 
+0

난 이미 가지고 있는데. 그러나, 재미를 위해서 나는 어쨌든 그것을 시도 ... 그리고 나는 동일한 결과를받습니다. 내 두 번째보기는 세로 모드가 아닌 가로 모드로로드됩니다. – bpatrick100

+0

네,하지만 PortraitUpsideDown도 처리합니다. – robertvojta

+0

그리고 비 기능적 회전의 이유는 shouldAutorotate ...가 물리적 장치 회전시에만 호출된다는 것입니다. 이 질문을 확인하십시오 - http://stackoverflow.com/questions/2922919/transitioning-to-landscape-rotation-within-a-ininavigationcontroller – robertvojta

관련 문제