【问题标题】:I don't know how to do Portrait and Upside down in iOS 6我不知道如何在 iOS 6 中进行 Portrait 和 Upside down
【发布时间】:2012-12-03 19:02:14
【问题描述】:

我正在使用:

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskPortrait; 

}

如何在 iOS6 中将其用于 Portrait 和 Upside down?

这适用于横向左侧UIInterfaceOrientationMaskLandscapeLeft

这个是横向的UIInterfaceOrientationMaskLandscapeRight

这适用于两种风景UIInterfaceOrientationMaskLandscape

【问题讨论】:

    标签: iphone objective-c xcode ios6 uiinterfaceorientation


    【解决方案1】:

    我也遇到了同样的问题here

    你也应该解决你的问题。

    • 允许旋转
    • 顶部组件需要再次允许

    仔细观察那些方法,看起来很相似,其实不然

    【讨论】:

      【解决方案2】:

      您需要对每个支持的方向使用按位或运算符。

      - (NSUInteger)supportedInterfaceOrientations {
          return UIInterfaceOrientationMaskPortrait |
              UIInterfaceOrientationMaskPortraitUpsideDown; 
      }
      

      为您要支持的每个方向添加另一个按位或。通常,当您看到其中包含“掩码”一词的常量时,它们应该以这种方式组合。

      【讨论】:

        【解决方案3】:

        您需要返回您希望支持的方向的有效位掩码:

        纵向和纵向倒置:

        - (NSUInteger)supportedInterfaceOrientations {
        
            return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
        
        }
        

        你可以看到supported orientation masks的列表

        还需要注意的是,您还需要在支持的方向上颠倒列出纵向:

        【讨论】:

        • 我已经在项目设置中完成了这项工作,感谢提供代码。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-05-18
        • 1970-01-01
        • 1970-01-01
        • 2020-04-02
        • 1970-01-01
        • 2023-03-23
        • 2023-03-30
        相关资源
        最近更新 更多