APP只支持豎屏(Portrait)模式
- 在project navigator中選擇對(duì)應(yīng)的工程,在選中target后,選擇General標(biāo)簽,然后保證Device Orientation中只有Portrait被選中即可。如下圖所示。 (這一步只能保證APP在iPhone上只支持豎屏)
portrait.png
這里介紹的Device Orientation選項(xiàng),與Info.plist文件中的Supported interface orientations選項(xiàng)相對(duì)應(yīng)。
- 如果APP同時(shí)支持iPad,且在iPad上只支持豎屏,則還需要按如下步驟操作:打開Info.plist文件,找到Supported interface orientations (iPad)選項(xiàng),刪除Landscape (left home button)和Landscape (right home button)選項(xiàng),并保留Portrait相關(guān)選項(xiàng)(如果想要豎屏?xí)r保持home鍵在下,還要?jiǎng)h除Portrait (top home button)選項(xiàng))。
APP只支持橫屏(Landscape)模式
- 在project navigator中選擇對(duì)應(yīng)的工程,在選中target后,選擇General標(biāo)簽,然后保證Device Orientation中只有Landscape Left和Landscape Right被選中。(這一步只能保證APP在iPhone上只支持橫屏)
- 如果APP同時(shí)支持iPad,且在iPad上只支持橫屏,則還需要按如下步驟操作:打開Info.plist文件,找到Supported interface orientations (iPad)選項(xiàng),刪除Portrait (bottom home button)和Portrait (top home button)選項(xiàng),并保留Landscape相關(guān)選項(xiàng)。
- 上面2步已經(jīng)能保證APP在設(shè)備上只支持橫屏,如果想在Storyboard里讓view按橫屏顯示,還需要按如下步驟操作。
- 選擇對(duì)應(yīng)的view controller
- 在Inspector面板里找到“Attributes inspector”
- 修改Simulated Metrics里的Orientation設(shè)置,將默認(rèn)配置Inferred(對(duì)應(yīng)Portrait),改成Landscape。(這個(gè)要在去使能size class的情況下才有效)