【问题标题】:How does one force portrait launch for an otherwise universally-oriented app?一个面向其他普遍面向的应用程序如何强制启动肖像?
【发布时间】:2016-05-09 20:39:37
【问题描述】:

我的通用应用程序允许某些视图控制器处于横向,但不是第一个屏幕。启动图像看起来像第一个屏幕;在 iPhone 上运行时,它需要是纵向的。在 iPad 上,所有方向都是可接受的。如何处理?

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {

不能用于启动情节提要的视图控制器。 ????

【问题讨论】:

  • 只需将启动图像置于纵向模式,其余部分在supportedInterfaceOrientations 中处理

标签: ios xcode uikit uistoryboard


【解决方案1】:

在您的项目列表中添加“初始界面方向”键。将值设置为“纵向(底部主页按钮)”或其他一些所需值。转到项目文件的“常规”选项卡并取消选择设备方向。在您的视图控制器中覆盖 supportedInterfaceOrientations


这是一个很好的开始!这是还需要什么...... - Jessy

Initial interface orientation 是字符串键 UIInterfaceOrientation 的美化名称。 Creating and Editing an Information Property List File 文档告诉我们,我们需要一个特定于 iPhone 的条目,如下所示:

<key>UIInterfaceOrientation~iphone</key>
<string>UIInterfaceOrientationPortrait</string>, 

因为这是默认设置,所以没有必要指定它。但是,必须为Supported interface orientations (iPad) 键指定所有四个值,这是UISupportedInterfaceOrientations~ipad 的美化版本。 UIInterfaceOrientation is ignored if the UISupportedInterfaceOrientations key is present,所以~ipad 部分必须存在。

【讨论】:

  • 你试过了吗?因为这实际上只适用于 iPad 和 iPhone 6 plus,所以我测试了这些设备。
  • 我的应用程序仅在 iPhone 上运行,我希望它以纵向启动。我尝试将 UIInterfaceOrientation 设置为纵向,将 UISupportedInterfaceOrientations~iphone 设置为所有三个(纵向、左侧横向、右侧横向)。但如果在应用程序启动之前主屏幕是横向的,它仍会在 iPhone 7 Plus 上横向启动。我该如何解决?谢谢。
  • 同意,这个答案不正确。如果设备在启动时保持横向,启动屏幕仍将显示为横向。 (甚至做这个答案中提到的)。我们应该注意,我们必须在 UISupportedInterfaceOrientations 中添加“几乎颠倒”。
  • 为我工作。谢谢!
猜你喜欢
  • 1970-01-01
  • 2019-01-24
  • 2018-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-14
相关资源
最近更新 更多