一个强制肖像如何为一个原本面向通用的应用程序启动?
How does one force portrait launch for an otherwise universally-oriented app?
我的通用应用程序允许某些视图控制器处于横向状态,但不是第一个屏幕。启动图像看起来像第一个屏幕;在 iPhone 上 运行 时需要纵向。在 iPad 上,所有方向都可以接受。如何处理?
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
不能用于启动情节提要的视图控制器。
将 "Initial interface orientation" 键添加到您的项目 plist。将值设置为 "Portrait (bottom home button)" 或其他一些所需的值。转到项目文件的 "General" 选项卡并取消选择设备方向。在您的视图控制器中覆盖 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
部分必须存在。
我的通用应用程序允许某些视图控制器处于横向状态,但不是第一个屏幕。启动图像看起来像第一个屏幕;在 iPhone 上 运行 时需要纵向。在 iPad 上,所有方向都可以接受。如何处理?
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
不能用于启动情节提要的视图控制器。
将 "Initial interface orientation" 键添加到您的项目 plist。将值设置为 "Portrait (bottom home button)" 或其他一些所需的值。转到项目文件的 "General" 选项卡并取消选择设备方向。在您的视图控制器中覆盖 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
部分必须存在。