2011-07-31 1 views
3

특정 상황에서 가로 모드를 지원할 수 있도록 shouldAutorotateToInterfaceOrientation:을 재정의하기 위해 UITabBarController를 하위 클래스로 만들었습니다. 나는이 프로그램을 실행할 때 오버라이드 (override)되는 메소드가 shouldAutorotateToInterfaceOrientationYES 모든 시간을 돌아보다 NOUITabBarController가 ".. 적어도 하나의 오리엔테이션 지원"메시지를 반환하는 이유는 무엇입니까?

The view controller <...0x644f50> returned NO from -shouldAutorotateToInterfaceOrientation: for all interface orientations. It should support at least one orientation.

다른 메시지를 타고하는 방법에 대한 어떤 제안을 반환 할 때, 탭 표시 줄 컨트롤러는 나에게 다음과 같은 메시지를 준다?

답변

13

NO를 반환하면보기 컨트롤러가 네 방향 중 하나로 표시 될 수 없음을 의미합니다.

지원할 방향을 생각하고 방향을 허용하는 orientation 매개 변수를 사용해야합니다. 내가 세로 및 가로 권리를 지원하기 위해 내보기 컨트롤러를 원하는 경우 예를 들어

는이 내 구현 될 것이다 (이것은 선으로 감소 할 수 있지만, 나는 명확성을 위해 그것을 확대하고있어) :

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIDeviceOrientation)orientation{ 
    if(orientation == UIDeviceOrientationPortrait) return YES; 
    if(orientation == UIDeviceOrientationLandscapeRight) return YES; 
    return NO; 
} 
+0

정보 주셔서 감사합니다. 그것은 문제를 해결했습니다. – David

0

UIInterfaceOrientationIsLandscape() 및 UIInterfaceOrientationIsPortrait()를 사용하여 UIViewController에서 지원할 특정 방향을 처리 할 수 ​​있습니다.

관련 문제