I am using this code.
For example, I have view1 (portrait only) and view2 (portrait+landscape). When you are in view1 and click a button, you open view2 with popup on the whole screen. When you close view2 and view1 become visible, I want to automatically turn it to portrait mode, if view 2 was in landscape. Any suggestions?
As you've said you were using popup, I'm sure you're using a navigationController. here's the view hierarchy.
There are three viewControllers corresponds to those xib.
The viewController is set to
portrait
only, and the secondViewController is set toportrait and landScapeLeft
(you can change it to whatever you need). It works just fine as you required. When the second one is in landscape, pop to the first, it will be forced to set to portrait.NavViewController
ViewController
SecondViewController
//NavViewController.swift
//ViewController.swift
SecondViewController.swift class SecondViewController: UIViewController {