I have the answer.
On AppDelegate
, if you rotate device, push viewcontroller, etc. This function always call
Update for swift 3/4
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask
{
return self.restrictRotation
}
self.restrictRotation
is a custom parameter.
How to use:
In Appdelegate:
var restrictRotation:UIInterfaceOrientationMask = .portrait
In ViewController:
When method ViewDidLoad or viewWillAppear is called. We will change like this:
(UIApplication.shared.delegate as! AppDelegate).restrictRotation = .all
and then this method on AppDelegate will be called.
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…