代码之家  ›  专栏  ›  技术社区  ›  Tejas Ardeshna Shwethascar

iOS 7中的定向问题

  •  0
  • Tejas Ardeshna Shwethascar  · 技术社区  · 9 年前

    我有一个奇怪的问题,我的应用程序处于横向模式。它在iOS 8中运行良好,但在iOS 7中,应用程序的第一个屏幕处于肖像模式。如果我推到另一个viewController并返回到第一个vc,那么它将进入我想要的横向模式

    - (BOOL)shouldAutorotate
    {
        return NO;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscape;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationLandscapeRight;
    }
    
    1 回复  |  直到 9 年前
        1
  •  2
  •   Pepeng Hapon    9 年前

    我还遇到了一个关于取向的问题…那就是iPhone。

    我记得在运行我的应用程序时,当我希望将应用程序默认为横向模式时,默认方向是纵向。所以我把代码放在下面,它解决了我的问题。

    - (BOOL) shouldAutorotate {
        return YES;
    }
    - (NSUInteger) supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskLandscape;
    }
    - (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
        return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
    }
    

    应自动旋转 返回YES,因为我希望它在第一次运行时在Landscape中旋转。

    希望这个故事对你有所帮助,祝你好运。