【问题标题】:Landscape oreintaton not working for ios 6横向不适用于ios 6
【发布时间】:2023-03-15 05:12:01
【问题描述】:

我正在开发一个 iPhone 应用程序,我必须在其中将 oreintation 更改为 Landscapeleft 和 Landscaperight。它在 iPhone 4 中工作,但在 iPhone 5 中不工作。请让我知道如何为 ios 6 做。我的代码使用如下。

谢谢。

【问题讨论】:

    标签: objective-c ios ios6 landscape


    【解决方案1】:

    添加此代码

    -(NSUInteger)supportedInterfaceOrientations
    {
        return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight);
    }
    

    它对我有用 希望对你有帮助!

    编辑

    同时添加此代码

    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    

    【讨论】:

    • 如果您使用的是 presentViewController,请参考此链接:stackoverflow.com/questions/12566780/…
    • 谢谢,我使用了你的代码,但是没有用,还有其他地方我需要修改吗?
    • 尝试添加我在答案的编辑部分添加的代码
    • 谢谢,但我添加了你给我的代码,但它仍然不起作用。我添加的代码是 -(NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight); } - (BOOL)shouldAutorotate { 返回 YES;有没有其他方法可以做到这一点。
    • 您的应用程序使用的是 presentViewController 还是 presentModalViewController?
    【解决方案2】:

    它不像在 IOS6 中那样好用,我遇到了同样的问题。因为他们引入了新的旋转,但是运行导航控制器的旧方式(因为我的应用程序也需要支持 4.3)确实做到了非常难。

    阅读我的问题和解决方案应该可以帮助到你:

    my ansswer

    【讨论】:

      【解决方案3】:

      试试这个

      -(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
      {
      
          return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
      }
      
      -(BOOL)shouldAutorotate
      {
      
          return YES;
      }
      
      -(NSUInteger)supportedInterfaceOrientations
      {
      
          return UIInterfaceOrientationMaskLandscapeRight;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-06
        • 1970-01-01
        • 2013-02-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多