【问题标题】:Rotation method called in child view of UINavigationController?UINavigationController 的子视图中调用的旋转方法?
【发布时间】:2013-01-12 18:00:47
【问题描述】:

我在导航控制器中嵌入了一个视图层次结构。当视图旋转时,子视图控制器中会调用哪些方法?这段代码在导航控制器的一个子视图中,这些方法都没有被调用!

-(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");
}

谢谢!

【问题讨论】:

    标签: iphone ios ipad uinavigationcontroller rotation


    【解决方案1】:

    你应该得到两个

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

    所以您的设置有其他问题。

    要清楚,正如你提到的“子视图” - 你的意思是最顶层的 UIViewController?那就是在轮换期间拦截这些消息的那个。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-04
      • 2011-10-27
      • 2010-11-03
      • 2013-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多