iOS 画面を(portrait)縦固定にしても、window が横画面サイズになる。

xcode8 general

全部縦固定していたはずなのに、なぜかipadだけランドスケープ(横画面)で起動する。。
ちょっとおかしいと思って色々調べたメモ


環境

  • xcode8
  • Mac OS El Capitan

症状

  • xcodeの設定で General で
    Devices : Universal で、
    Device Orientation: Portrait のみの設定
  • iPadで横画面状態で、アプリを起動

するとUIWindowでサイズを取得すると縦画面のサイズと違うサイズが取得される、
むしろ、縦より横のサイズが大きい!
横画面のサイズになっているっぽい。。

DevicesをiPhoneにし、Portrait のみでも結果同じだった。

画面サイズを取得して、UIViewとか、UIを作っているところが、
予想外の動きにになりまくり。。


対策

設定画面のGeneralの

  • Devices: Universalに。
  • info.plistファイルにて記述されている UISupportedInterfaceOrientations~ipad
    の中を UIInterfaceOrientationPortrait のみにする。

設定画面のDevicesでプルダウン切り替えでipadの内容が保持されているのはあとから知ったw

info.plist

〜
<key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
</dict>
</plist>
〜
  • General設定画面の Required full screen にチェックを入れる
xcode8 general
xcode8 general

ただ、iPadでは、マルチタスキング機能というものがあって(Slide OverやSplitView)が使えなくなってしまうようなのでご注意を。

参考記事さま http://qiita.com/jollyjoester/items/c8bb1592d01fdef663f9