1、AppDelegate
(1)定义变量 var blockRotation: Bool = false
(2)定义方法
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask { if self.blockRotation{ return UIInterfaceOrientationMask.All } else { return UIInterfaceOrientationMask.Portrait } }
2、要横屏的viewController
(1)获取变量
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
(2)在viewDidLoad中修改blockRotation变量值
overrid