나는 UITabBarController
과 UINavigationBarController
의 계층 구조를 가진 자식 UIViewController
을 가지고 있습니다. 그것을 ChildViewController
이라고 부르 자. 내 계층 구조는 다음과 같습니다.계층 구조의 하위 UIViewController에서만 회전 지원?
UITabBarController
|
UINavigationViewController [tab 1]
|
SomeParentViewController
|
SomeOtherParentViewController
|
ChildViewController
이제 가로 방향으로 회전을 지원하려면 ChildViewController
만 허용하면됩니다. (채팅보기를 보여주는보기 컨트롤러이고 일부는 가로 모드를 사용하는 것이 더 쉽습니다.) 가로 방향을 지원한다고 선언하려면 - (BOOL) shouldAutorotateToInterfaceOrientation:
에서 까지의 메서드를 추가했지만 장치를 회전해도 아무런 효과가 없었습니다. 디버깅에서 나는 – willAnimateRotationToInterfaceOrientation:duration:
이 호출되지 않는 것을 발견했습니다.
온라인으로 검색 한 결과 UITabBarController
자체가 해당 방향을 지원할 경우 UITabBarController
의 자손은 지정된 방향 만 지원한다는 것을 발견했습니다. 그리고 이상하게도 각 탭의보기 컨트롤러가 회전을 지원하는 경우에만 UITabBarController
이 방향을 지원합니다. 위의 탭 1과 마찬가지로 다른 세 탭의보기 컨트롤러는 UINavigationViewController
인스턴스입니다. 우리가 더 깊이 들어가야하기 때문에 각 UINavigationViewController
은 자식보기 컨트롤러가 방향을 지원할 경우에만 방향을 지원합니다. - (BOOL) shouldAutorotateToInterfaceOrientation:
SomeParentViewController
에와 ChildViewController
회전 할 수 다른 UINavigationController
인스턴스의 자식을 추가하는 추가하는이 시점에서 그래서
SomeParentViewController
이고 다른 세 개의 탭은 가로로 회전하며보기에는 끔찍합니다. 나는 단지
ChildViewController
가 경관을 지원할 수 있기를 바랍니다.
래치 도트 노력으로 RotatingUITabBarController
이라는 고유 한 UITabBarController
하위 클래스를 만들고 ChildViewController
클래스에 전역 플래그를 추가하여 해당 플래그가 작성되어 표시되는지 여부를 알려줍니다. 나는 응용 프로그램을 부팅 할 경우 대신 세로 유지 SomeParentViewController
또는 다른 탭으로 전환 및 가로 모드로 전환되지 않는 전화를 회전, 지금
if ([ChildViewController isDisplayed]) {
return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) ||
(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
return NO;
: 만 - (BOOL) shouldAutorotateToInterfaceOrientation:
과 RotatingUITabBarController
재정의로 구현됩니다. 여태까지는 그런대로 잘됐다. ChildViewController
을 만들고 표시하고 전화를 돌리면 풍경이됩니다. 여태까지는 그런대로 잘됐다. 그러나 SomeOtherParentViewController
을 표시하기 위해 ChildViewController
을 팝하면 가로로 표시됩니다. 그리고 SomeParentViewController
과 다른 모든 탭으로 전환됩니다.
저는 속임수입니다. 어떤 충고라도 감사 할 것입니다, 고마워요!