Utku Eray
Utku Eray

Reputation: 23

How to present UIViewController to landscape and dismiss to portrait without ever rotating previous ViewControllers?

I cannot share any code or images about the project, that's why I will try my best to explain the situation.

The app is forced portrait mode but there is only one case where I need to present in landscape mode. When I present and dismiss the landscape ViewController, views in the previous ViewController get buggy. It happens especially with UITableViews. If I am not mistaken, it's happening because when I present a ViewController in landscape mode, other ViewControllers presented in UIWindow also rotate in the background.

I tried to use a second UIWindow and present the landscape ViewController in the second window. I thought it would only rotate ViewControllers in the second UIWindow but it seems it rotates the main window as well.

Is there any way to force a view controller from rotating ever so that I can keep previous ViewControllers in portrait mode all the time or is there a way to make tableViews prone to this behaviour?

Note: I may present the landscape ViewController in portrait mode and manage views by myself to look like it's in landscape mode but I would prefer a more elegant solution if possible. I also checked out this thread (Present UIViewController in Landscape mode in Portrait only app) but not sure if it would solve this problem because I want my landscape mode to rotate left-right properly.

Upvotes: 0

Views: 97

Answers (0)

Related Questions