【问题标题】:Disable Landscape Orientation in IOS5在 IOS5 中禁用横向方向
【发布时间】:2012-12-14 05:44:53
【问题描述】:

我想在为 IOS 5 构建的应用程序中消除横向方向。在 IOS 6 中我知道这是可能的 - 但在早期版本中它似乎不适用于我。

我在plist 文件中只设置了两个方向(顶部带有主页按钮的纵向和底部带有主页按钮的纵向)。无论如何,iOS 5 中仍然会出现 Landscape。

我还需要做些什么来消除这种情况吗?

【问题讨论】:

    标签: iphone objective-c ios landscape uiinterfaceorientation


    【解决方案1】:
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
       // return (interfaceOrientation == UIInterfaceOrientationPortrait);
       if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight)
     {
       return NO;
     }
     else
     {
       return YES;
     }
    
    }
    

    将此代码写入 .m 文件以用于 ios5 方向

    让我知道它是否有效....

    编码愉快!!!!

    【讨论】:

      【解决方案2】:

      这会奏效。转到情节提要取消选择您不想要的方向并在视图控制器中编写以下代码:

      - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      {
          return (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation==UIInterfaceOrientationPortrait );
      }
      

      【讨论】:

      • 它在 IOS 5 中不起作用。如何禁用横向方向?可以帮助我吗。谢谢提前
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-31
      • 2012-08-24
      • 2020-04-29
      • 1970-01-01
      • 2021-01-26
      相关资源
      最近更新 更多