0

I have disabled all orientation modes except the portrait one in my info.plist file because I don't want the app to rotate. However I want one view controller to be only in landscape mode. Can I change the orientation programmatically in the class of the view controller? Or can i disable autorotation in info.plist but enable portrait and landscape mode?

Also I know that I can check the orientation the phone is hold by UIDevice.currentDevice().orientation.isLandscape

But is there a method that gets executed when you hold your phone differently?

Lenny1357
  • 748
  • 1
  • 13
  • 21

2 Answers2

0

See in UIViewController.h the shouldAutorotate and supportedInterfaceOrientations methods.

  • I tried to use the supportedInterfaceOrientations a method but the view did not rotate. Also the should autorotate method does not work when only Portrait is allowed. Or are they only working together? – Lenny1357 May 18 '16 at 15:18
0

If you want to do present just one VC in an orientation different from the most of the others in the info.plist you must set a set of values that comprehends all the supported orientation.
To avoid the possibility of a VC to rotate in a particular orientation you should override

- shouldAutorotate
- supportedInterfaceOrintation
- preferredInterfaceOrientationForPresentation

You will find useful also this answer with a practical example How to force view controller orientation in iOS 8?

Community
  • 1
  • 1
Andrea
  • 26,120
  • 10
  • 85
  • 131