如何为一个普遍应用的应用强制推出肖像?

时间:2016-05-09 20:39:37

标签: ios xcode uikit uistoryboard

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

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {

无法用于发布故事板的View Controller。

1 个答案:

答案 0 :(得分:2)

将“初始界面方向”键添加到项目plist中。将值设置为“纵向(底部主页按钮)”或其他一些所需的值。转到项目文件的“常规”选项卡,然后取消选择设备方向。在您的视图中,控制器覆盖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部分必须存在。

相关问题