Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS >> Device Orientation >> Screen is Not Supporting Upside Down

I have a screen that supports Device Orientation.

Everything is working fine except for the fact that when I rotate the device upside down (home button at top), the rotation doesn't work (it's stuck on the last landscape settings).

I know of several places needed be updated to support this:

  • In the VC itself, I added the methods:

enter image description here

  • In the Project Target, I updated as follow:

enter image description here

  • In the Storyboard VC Scene, I updated as follow:

enter image description here

What am I missing here?

like image 420
Ohad Regev Avatar asked Nov 21 '13 14:11

Ohad Regev


People also ask

Why can’t I Turn my iPhone screen upside down?

The device, application and view controller all need to agree for the orientation to work. By default, a view controller doesn’t allow upside down on an iPhone regardless of what you specify for the application. To fix this, we can override this property in the view controller and return .all.

How to rotate iPhone app upside down?

To rotate upside down on older iPhones add upside down as a supported orientation in Info.plist or using the App delegate and override the supported interface orientations in the root view controller (you probably shouldn’t do this). But the plans were on display…

How to fix “view controller cannot allow upside down” on iPhone?

By default, a view controller doesn’t allow upside down on an iPhone regardless of what you specify for the application. To fix this, we can override this property in the view controller and return .all.

How do I change the orientation of an iPhone screen?

The device, application, and view controller settings must all agree for an orientation to work. To rotate upside down on older iPhones add upside down as a supported orientation in Info.plist or using the App delegate and override the supported interface orientations in the root view controller (you probably shouldn’t do this).


2 Answers

You also have to allow rotating to all orientations in every parent view controller of the current main view controller. For example, if your view controller is in navigation controller, try subclassing it and override the same methods as in your example.

Edit: As @JordanC mentioned, since iOS 7 you can implement UINavigationControllerDelegate method to return custom supported orientations:

- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController
like image 70
Tricertops Avatar answered Oct 17 '22 00:10

Tricertops


As @eGanges mentioned the key point could be to subclass your UITabBarController (and override supportedInterfaceOrientations) if that is your initial view controller, in that case this is the only controller you should subclass (and of course you should add all the supported interface orientations to your app Info.plist file UISupportedInterfaceOrientations key)

like image 31
Hofi Avatar answered Oct 17 '22 01:10

Hofi