In AppDelegate
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { if let presentedViewController = window?.rootViewController?.presentedViewController { let className = String(describing: type(of: presentedViewController)) if ["MPInlineVideoFullscreenViewController", "MPMoviePlayerViewController", "AVFullScreenViewController"].contains(className) { return UIInterfaceOrientationMask.allButUpsideDown } } return UIInterfaceOrientationMask.portrait }
source share