当应用程序在iPad上以横向模式启动时,旋转无法正常工作

时间:2015-05-07 10:12:50

标签: ios objective-c ipad rotation orientation

我在IPad> ios8.0上遇到问题。 在纵向模式下,所有工作正常。但是当我以横向模式启动应用程序时,它会出错 - http://prntscr.com/72huah

  1. 以横向模式启动应用程序。(正确显示)。
  2. 转到肖像。 (什么都没发生)。
  3. 转回风景
  4. 我在主ViewController中使用xib:

    - (NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationPortrait;
    }
    
    - (BOOL)shouldAutorotate {
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    
        if (orientation == UIInterfaceOrientationPortrait ||
            orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
            return YES;
        return NO;
    }
    

1 个答案:

答案 0 :(得分:0)

应用启动图像在视图后不会旋转(iOS不会这样做)。您可以添加 UIImageView 并在 UIInterfaceOrientation 的基础上旋转它。几次之后你可以删除Launch UIImageView。

- (BOOL)shouldAutorotate {
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

    if (orientation == UIInterfaceOrientationPortrait ||
        orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight){
   //Set LandScape Image to UIImageView
      return YES;
}
       //Set Portrait Image to UIImageView 
    return NO;
}