0

I have released an app, and for some reason only some people are having an orientation issue with the app. Namely that it is opening in Portrait mode, and is un-rotatable from here where as the app is set up to only be allowed in LandscapeLeft and LandscapeRight. Most people aren't having this issue, however I've received a few complaints recently through our support page.

People with the issue seem to be on iOs 5.1 and iPad gen 1s, which is the lowest OS my app supports.

Here is the code handling the rotation:

   - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
   {
       if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
       {
           return YES;
       }
       else
       {
           return NO;
       }
   }

And here is the .plist

http://tinypic.com/r/nnvfhz/6

Any suggestions would be great.

SamBo
  • 551
  • 2
  • 6
  • 13
  • Are you using AutoLayout? – Firo Jan 31 '13 at 02:12
  • No, i'm not using AutoLayout in storyboards. – SamBo Jan 31 '13 at 02:21
  • Is this code in your top view controller? – Firo Jan 31 '13 at 02:32
  • I have a navigation view controller before this view controller. I have some code handling the navigation view, so maybe I should also add this method to that? I just can't see why it works perfectly on some devices with iOs 5.1 but not others.... – SamBo Jan 31 '13 at 02:38
  • I am wondering if it has something to do with the device's orientation upon start. If it launches in landscape it will probably stay there because this view is loaded and it holds that to be true. But if the user launches the app in portrait this view is not loaded yet and it loads the app in that view. Since this code only executes when the device is tilted it does not force it until that happens. If people believe the app only works in landscape they will probably only launch it in landscape making it uncommon for normal users to see this problem yet edge cases could remain. Just a thought. – Firo Jan 31 '13 at 02:42
  • Yeah I did think maybe that was the case. But my .plist has the 2 support interfaces as LandscapeLeft & LandscapeRight. Shouldn't that be enough to force the the app to load in landscape? I feel the solution will be me adding the autorotate code into the Navigation view controller. – SamBo Jan 31 '13 at 02:52
  • Yeah, you would think. You could look at this: http://stackoverflow.com/questions/5888016/ios-device-orientation-on-load Somewhat unrelated but could have something to do with your issue. – Firo Jan 31 '13 at 02:57

1 Answers1

1

In iOS5, you must override the shouldAutorotateToInterfaceOrientation: method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // support all interface orientations
    return YES;
}

This method was deprecated as of iOS 6, for which you should use these:

- (BOOL)shouldAutorotate {
    // return whether autorotation is supported
    return TRUE;
}
- (NSUInteger)supportedInterfaceOrientations {
    // return the mask that represents the supported interface orientations
    return UIInterfaceOrientationMaskAll;
}

Finally, I'll mention this method, since it's often applicable:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    // set the preferred orientation of view controllers presented in full-screen
    return UIInterfaceOrientationLandscapeRight;
}
Anton
  • 3,998
  • 25
  • 40
  • @Anton did you even look at the code SamBo posted? Your method signature is also incorrect. You have no argument associated with UIInterfaceOrientation. – Firo Jan 31 '13 at 02:27
  • 1
    @Joel: yep, I read the whole code and then it totally went over my head for some reason :) Oops.. I corrected the method signature in the code though, thanks. – Anton Jan 31 '13 at 02:33