2013-01-12 36 views
0

我有一個視圖層次結構嵌入導航控制器。視圖旋轉時在子視圖控制器中調用哪些方法?此代碼位於導航控制器的其中一個子視圖中,並且這些方法都不會被調用!在UINavigationController的子視圖中調用的旋轉方法?

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
    NSLog(@"1"); 
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ 
     return true; 
    }else{ 
     if(toInterfaceOrientation == UIInterfaceOrientationPortrait){ 
      return YES; 
     } 
    } 

    return false; 

} 

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 
    [self loadCorrectElements]; 
    NSLog(@"2"); 
} 

謝謝!

回答

0

你應該得到雙方的

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 

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

所以別的東西是不對您的安裝。

要說清楚,正如你提到的「孩子的意見」 - 你的意思是最高的UIViewController?這是在輪換期間攔截這些消息的那個。