【问题标题】:App displaying in landscape when on iPhone mode on iPad在 iPad 上的 iPhone 模式下,应用程序以横向显示
【发布时间】:2013-03-23 01:04:11
【问题描述】:

当我的应用在 iPhone 上启动时,它会按原样纵向显示。当它以 iPhone 模式在 iPad 上启动时,如果以这种方式旋转,它将以横向显示。这是我的代码:

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

-(BOOL)shouldAutorotate {
    return NO;
}

【问题讨论】:

  • 在摘要部分的项目设置中将支持的方向设置为仅纵向

标签: iphone ios objective-c ipad screen-orientation


【解决方案1】:

对于 iOS 6,你有没有尝试:

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

【讨论】:

    【解决方案2】:

    在您的项目 info.plist 文件中,从支持的方向列表中删除横向标志。

    【讨论】:

      【解决方案3】:

      在 Xcode 中选择您的目标之一,然后在摘要选项卡下确保您只选择了 UIpotrait 方向,其余所有这些都未选中,然后选择信息选项卡并查看“支持的界面方向”行下它应该只有 UIpotrait 方向.现在打开您的委托文件,对于 ios5,此方法有效

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

      但此方法在 iOS6 中已被弃用,以便为 iOS6 覆盖它

      -(BOOL)shouldAutorotate {

      return YES;
      

      }

      -(NSUInteger)supportedInterfaceOrientations {

      return UIInterfaceOrientationMaskPortrait;
      

      } - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{

      return UIInterfaceOrientationMaskPortrait;
      

      }

      -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

      return UIInterfaceOrientationPortrait;
      

      }

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-06
        • 2014-10-25
        • 1970-01-01
        • 2012-10-11
        • 2013-06-01
        相关资源
        最近更新 更多