【问题标题】:Why is my iPad app not detecting orientation change?为什么我的 iPad 应用程序没有检测到方向变化?
【发布时间】:2012-01-25 16:25:09
【问题描述】:

使用以下代码没有给我任何东西...我的视图旋转。看不懂……

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


- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    NSLog(@"I am starting to rotate");
}

谢谢...

【问题讨论】:

  • 你在嵌套视图控制器吗?
  • 原来我的视图控制器在一个容器中......

标签: objective-c ios ipad orientation


【解决方案1】:

这可能是由于您的 VC 嵌套在 VC 的层次结构中的方式。

This SO 帖子应该可以帮到你:

【讨论】:

    【解决方案2】:
    -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
        if(self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
           self.interfaceOrientation == UIInterfaceOrientationLandscapeRight){
               NSLog(@"I am starting to rotate in Landscape");
    
        } else {
               NSLog(@"I am starting to rotate in Portrait");
    
        }
    }
    

    并保持原样

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-12
      • 1970-01-01
      • 2019-10-02
      • 2022-01-16
      相关资源
      最近更新 更多