ios - iPad 应用程序以横向模式启动

标签 ios ipad uiinterfaceorientation

我搜索了其他现有帖子,但没有一个满足我的要求。

这是我面临的问题,

  1. 我的应用同时支持横向和纵向模式。
  2. 但我的第一个屏幕只支持 Landscape ,所以应用程序必须以 Landscape 启动。
  3. 我已经为所有 4 个选项设置了支持的方向
  4. 我已将初始界面方向设置为横向(左主页按钮)
  5. 在第一个屏幕的 View Controller 中,我定义了以下内容

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

    {
        return (interfaceOrientation != UIInterfaceOrientationPortrait);
    }

当我启动该应用程序时,模拟器总是以纵向模式打开,而我的 View 在纵向模式下一团糟,因为它专为横向设计。 切换到横向后,设备保持此模式。

谁能帮我解决这个问题?

谢谢 纳文

编辑:

This info may be helpful , The problem is faced only when i hold the device in Portrait and then launch the app.

这不是这个问题的重复,Landscape Mode ONLY for iPhone or iPad

Landscape Mode ONLY for iPhone or iPad

我不希望我的应用程序只在 Landscape 中,我只希望我的应用程序的第一个屏幕只在 Landscape 中。

最佳答案

我对我正在开发的具有相同要求的应用进行了一些试验,并得出以下结果:

  1. 要设置应用首次启动时支持的初始方向,请为您的目标使用“支持的设备方向”设置。 enter image description here 正如您已经完成的那样,还使用适当的 shouldAutorotateToInterfaceOrientation 代码对其进行支持。

  2. 对于后续屏幕,只需使用 shouldAutorotateToInterfaceOrientation 代码来确定您想要支持的方向。即使您只为支持的设备方向指定了横向模式,shouldAutorotateToInterfaceOrientation 也会胜出。 :)

我认为这种方法比使用额外的虚拟 VC 更简洁。

关于ios - iPad 应用程序以横向模式启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9295149/

相关文章:

ios - @property (nonatomic,retain) UISegmentedControl *colorChooser 中的警告;

ios - 以编程方式停止向 iPhone 发送短信

ios - 续订iOS发布配置文件

ios - 如何快速将 Airprint 方向设置为横向?

ipad - 状态栏方向问题

ios - 如何在 iOS 上的 OpenGL 中使用 fbx 文件?

ios - 模块 'Fabric' 没有名为 'with' 的成员

iphone - 如何通过 iPhone 中的 fbgraph api 显示 facebook 集成中的事件指示器

ios - 在 iOS 7 上压缩的 UITableView sectionIndexTitles

ios - 如果屏幕以纵向模式锁定,如何检测方向?