2010-08-21 12 views
5

장치가 가로 모드 인 경우 ModalViewController A를 밀어 내 기본 ViewController에서 -orientationChanged를 무시합니다. 다시 portrait 모드로 전환하면 ModalViewController A가 닫힙니다. 그러나 ModalViewControllerB, C 또는 D가 표시된 다른 경우 (단추를 누른 후)가 있습니다. 그것들이 보여 질 때, 장치가 가로 방향으로 돌아가고 되돌아 가면, ModalViewController B C 또는 D는 부적절하게 닫혀 버립니다.ModalViewController가 표시되는지 어떻게 알 수 있습니까?

ModalViewController가 표시된 경우에도 내 ViewController에서 -orientationChanged가 메시지로 보내지는지 확인할 수 있습니다. ModalViewController B C 또는 D가 표시 될 때 해당 코드를 무시하도록 -orientationChanged 메서드에 추가 할 수있는 조건이 있습니까?

감사합니다.

답변

6

기본 viewcontroller의 modalViewController 속성이보기 컨트롤러 중 하나인지 확인할 수 있습니다.

+2

감사합니다. 나는 조건부를 사용했다 : if ([self.modalViewController isMemberOfClass : [UINavigationController class]]) ... – ed94133

1

이 코드를 사용하여 마지막 ModalViewController를 찾을 수 있습니다.

UIViewController *leafController = self; 
while(true) { 
    if (leafController.modalViewController) { 
     leafController = leafController.modalViewController; 
     continue; 
    } 
    break; 
} 
[leafController presentModalViewController:showController animated:YES]; 
관련 문제