Orientations

import Foundation
import UIKit

extension UINavigationController {
    open override var shouldAutorotate: Bool {
        if let vc = self.viewControllers.last {
            return vc.shouldAutorotate
        }
        return false
    }
    
    open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        if let vc = self.viewControllers.last {
            return vc.supportedInterfaceOrientations
        }
        return UIInterfaceOrientationMask.portrait
    }
}

extension UITabBarController {
    open override var shouldAutorotate: Bool {
        if let select = self.selectedViewController {
            return select.shouldAutorotate
        }
        return false
    }
    
    open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        if let select = self.selectedViewController {
            return select.supportedInterfaceOrientations
        }
        return UIInterfaceOrientationMask.portrait
    }
}

你可能感兴趣的:(Orientations)