【问题标题】:Portrait orientation only for iPad?仅适用于 iPad 的纵向?
【发布时间】:2010-04-27 13:46:32
【问题描述】:

根据苹果的说法,我的应用程序必须能够在两种纵向模式下运行。如何使用 shouldAutorotateToInterfaceOrientation 完成此操作?

【问题讨论】:

    标签: xcode ipad orientation portrait


    【解决方案1】:

    无论界面方向如何,都只返回 YES。这将允许系统自动旋转到倒置方向。

    如果您不想支持横向,则返回:

    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    

    【讨论】:

    • 我不希望用户能够在横向模式下玩,它不能正常工作。我只想要两种人像模式
    【解决方案2】:

    此代码允许除横向以外的任何方向:

    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
    {
        return (orientation != UIDeviceOrientationLandscapeLeft) &&
               (orientation != UIDeviceOrientationLandscapeRight);
    }
    

    【讨论】:

      【解决方案3】:

      提交的应用因上述原因被拒绝。应用仅使用纵向(Home Button Down)方向。

      ”应用程序不符合 Apple iOS 人机界面指南,如 App Store 审核指南所要求的。

      具体来说,应用只支持自下而上的纵向变体,不支持自上而上的变体。

      虽然支持两种方向的两种变体,每种都具有独特的启动图像,但可以提供最佳的用户体验并被推荐,但我们了解某些应用程序必须仅在纵向运行。在这种情况下,在您的应用程序中支持该方向的两种变体是合适的,例如,主页按钮向上和向下。”

      解决。 1)

       `- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      {
          // Return YES for supported orientations
          return UIInterfaceOrientationIsPortrait(interfaceOrientation);
      }
      

      2) 打开 info.plist 添加一个新字符串UILaunchImageFile & insert value as Default-Portrait.png

      3) 将 Default.png 更改为 Default-Portrait.png 并复制文件以重命名 Default-PortraitUpsideDown.png(将此文件旋转 180 度)

      这可以使用各自的启动图像启用上下纵向。

      如果需要,请确保在应用程序内的所有视图控制器中使用 UIInterfaceOrientationIsPortrait(interfaceOrientation)。运行前也要进行清洁。

      【讨论】:

        【解决方案4】:

        使用这个。

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

        【讨论】:

        • 为了提高您的回答质量,请说明您的帖子将如何/为何解决问题。
        猜你喜欢
        • 2012-07-10
        • 2014-12-24
        • 2013-03-02
        • 1970-01-01
        • 1970-01-01
        • 2017-08-28
        • 1970-01-01
        • 1970-01-01
        • 2013-04-30
        相关资源
        最近更新 更多