2011-04-25 3 views
7

가능한 중복 :
ViewController not responding to didRotateFromInterfaceOrientation회전했을 때 RotateFromInterfaceOrientation이 실행되지 않습니까?

나는 didRotateFromInterfaceOrientation 방법 내의 ViewController 서브 클래스 중 하나에 발사하지에 문제가 있어요.

기본보기로 UISplitViewController가있는 iPad 앱이 있습니다. Detail 측면에서, 저는 게으른 뷰 전환을위한 "hidden"(툴바, navbar 없음) 네비게이션 컨트롤러를 사용하고 있습니다. didRotateFromInterfaceOrientation을 잡으려는 ViewController는 navcontroller 계층 구조의 두 단계 깊이입니다. (이 중에 차이를하지 않습니다해야하지만, 내가 모르는 어떤 특별한 경우가있을 경우이 정보를 포함하고있어 약)

내가 가진 :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 

// This doesn't work. :(
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    NSLog(@"Rotate Go!"); 
} 

뷰가 잘 회전, 하지만 didRotateFromInterfaceOrientation은 결코 실행되지 않습니다.

내가 무엇을 놓치고 있는지 알 수 있습니까? 나는 내보기 여부를 감지하고있어

UISplitViewController 대리자 메서드에서

, splitViewController:willHideViewController:withBarButtonItem:forPopoverController:splitViewController:willShowViewController:invalidatingBarButtonItem: : 이벤트가 발사되지 않은 이유를

+0

uitabbar가 있습니까? 왜냐하면 uitabbar 클래스를 만들고이 클래스에서 "shouldAutorotateToInterfaceOrientation"을 구현하여 다른 모든 컨트롤러가 회전 메시지를 받도록해야하기 때문입니다. –

+0

Nope. UIToolbar 및 UINavigationController (툴바가 숨겨져 있으므로 다른 뷰가 다른 툴바를 공유 함)와 함께 UISplitViewController를 사용하고 있습니다. 그러나 UITabBar는 없습니다 ... – DOOManiac

+0

사과에 따르면, UISplitViewController는 응용 프로그램 창의 루트보기 여야합니다. 그럴리가 없으면 이상하게 느껴질 수 있습니다. 이 SO 스레드를 확인하십시오. http://stackoverflow.com/questions/2734016/uisplitviewcontroller-doesnt-autorotate –

답변

0

글쎄, 나는 알아낼하지 않았다 결코,하지만 해결 방법을 알아낼 않았다 그리고 나서 여기에서 나의 회전 논리를하고 있습니다.

5

UIViewController가 일부 루트보기의 하위 항목 인 경우 IB는 기본적으로 루트 컨트롤러에 하위 컨트롤러로이를 추가하지 않습니다. 이 문제를 해결하는 가장 쉬운 방법은 루트 컨트롤러를 수정하는 것입니다.

- (void)viewDidLoad 
{ 
    [super viewDidLoad];  
    [self addChildViewController:(UIViewController*) self.yourChildController]; 
} 

트릭을 수행해야합니다. 이제 자녀 컨트롤러는 모두 수신됩니다

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; 

메시지를.

+0

고마워! 이건 그냥 회전 이벤트를 받고 있지 않은 UISplitViewController와 함께 문제를 해결했습니다. – cberkley

관련 문제