I believe this is a common issue and many answers don\'t work anymore, many just partial, if you are under iOS7 and your iPad app is Landscape only, but you want to use the
Swift 4
solution
Make sure that when you are having the ViewController embedded in a NavigationViewController to have the fix there. It won't work adding this restriction to the ViewController then...
import UIKit
class MainNavigationViewController: UINavigationController {
override var shouldAutorotate: Bool {
return true
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscape
}
}
And of course the code mentioned above for the AppDelegate:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return .all
}
Btw this is only necessary for iOS 10 and below. Apple seems to have fixed it from iOS 11 and above...