アプリをビルドした時に、iPhoneは縦向き固定。iPadは、右左の横向き固定にしたい。
TARGETSのGeneralにある、Device Interfaceは、どれにもチェックしていません。
以下の記述で対応可能
ViewController.swift
// デバイスの向き変更
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
var orientation = UIInterfaceOrientationMask()
// iPhoneの時は縦固定、iPadの時は、横向きの右左固定
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
orientation = UIInterfaceOrientationMask.Portrait // 縦
} else {
orientation = [UIInterfaceOrientationMask.LandscapeRight,UIInterfaceOrientationMask.LandscapeLeft] // 右、左
}
return orientation
}
//指定方向に自動的に変更
override func shouldAutorotate() -> Bool{
return true
}
NavigationControllerを使っている場合は、上記の記述をそちらに書くとうまくいきます。