iPadでDevice OrientationをPortraitのみにする方法


iPadでは全てのOrientationに対応する必要があるようなのですが、Portraitのみにする方法があったので紹介します。

動作環境

Deployment Target: 11.0

対応方法

Requires full screen

Requires full screen` にチェックを入れます。

`

この設定を行うとマルチタスキング機能が使えなくなるため、御理解の上で設定下さい。

ちなみに、スクリーンショットで Portrait にのみチェックが入っていますが、この設定でもiPadでは Portrait 以外にもなります。

supportedInterfaceOrientations

対応が必要なViewControllerで以下の実装を行います

    override var shouldAutorotate: Bool { return true }
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait }

この2つでiPadでDevice OrientationをPortraitのみにする事ができました。

参考にした記事