3

I have just completed building a universal app which rotates perfectly on my iPhone, but on the iPad it just stands still.

Similar to this question, but that does not solve my issue.

The supported interface orientations are all set to allow rotation and I have even set this in my app delegate:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{ 
    return UIInterfaceOrientationMaskAll; 
} 

Still the iPhone rotates fine, but the iPad won't move from portrait.

What could cause this, or rather how can I fix it?

[UPDATE]

  • The switch on the side is not on lock.
  • The orientations in the PList are set correctly.
  • The Project settings (where you select it via buttons) are set correctly.
Community
  • 1
  • 1
Pangolin
  • 7,284
  • 8
  • 53
  • 67
  • 2
    Did you check your Project Settings? Make sure the iPad has all orientations checked. That seems to override all other code. – Josiah Jan 14 '13 at 02:00
  • 1
    Check if orientation of device is not locked. There is switch on right edge of iPad for locking orientation. – Rahul Wakade Jan 14 '13 at 02:44
  • @Rahul, haha thanks, but that was part of testing if the rotation works. Check the update please. – Pangolin Jan 14 '13 at 09:24
  • @LouwHopley yeah, but it happens, sometimes we don't remember that device has rotation lock and we keeps looking into code what's wrong. :) – Rahul Wakade Jan 15 '13 at 18:00

3 Answers3

6

@adam-s was right, except with Xcode 7.x there is no button below the "devices" selector.

With Xcode 7, you need to change "Universal" to "iPad" whereby the orientation selectors change to reflect iPad-only settings. Then you can change the selector back to "Universal".

Confusing!

Richard
  • 1,249
  • 16
  • 25
5

Don't forget to change the rotation settings for the target for both iPhone and iPad - note that there's an iPad button to the right of the iPhone one (which some people, such as myself, might miss at first glance):

enter image description here

Adam S
  • 16,144
  • 6
  • 54
  • 81
1

I fixed this by adding this piece of code to every ViewController of mine:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{ 
    return UIInterfaceOrientationMaskAll; 
}

It seems like this question's answer was correct after all. I just thought it wasn't since I checked through all the ViewControllers and found nothing restricting it from turning.

Community
  • 1
  • 1
Pangolin
  • 7,284
  • 8
  • 53
  • 67