6

Here is a simple single view controller app :

    - (void)viewDidLoad
    {
      [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

      self.view.backgroundColor = [UIColor greenColor];
     }


    - (BOOL)shouldAutorotate
    {
       return YES;
    }

    - (NSUInteger)supportedInterfaceOrientations
   {
        return UIInterfaceOrientationMaskLandscapeRight;
   }

The outputs are so different in iOS 8.

iOS 8 output

iOS 7 output

It's got to do with the difference in UIWindow bounds on iOS 8 vs iOS 7. How do I get iOS 7 like behavior ?

Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
  • 1
    Is your view controller the root view controller of a window that is the key window? – Zev Eisenberg Sep 08 '14 at 14:14
  • Zev, I'm having the exact same problem and I do have a view controller being set as the root view controller. Do you know more about this? – LunaCodeGirl Sep 30 '14 at 21:29
  • Another [question](http://stackoverflow.com/questions/24150359/is-uiscreen-mainscreen-bounds-size-becoming-orientation-dependent-in-ios8) like this has already been answered [here](http://stackoverflow.com/a/24153540/947342). – pxpgraphics Oct 07 '14 at 04:16

2 Answers2

0

This appears to be a bug in Xcode 6 or iOS 8. After switching to storyboards from xib, the problem disappeared.

Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
-1

In IOS8 the list of possible orientations should be in the Info.plist file, the method shouldAutorotate return YES by default.

Take a look on the discussion and documentation below:

https://stackoverflow.com/a/24467576/3330421

UIKit Reference: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/supportedInterfaceOrientations

When the user changes the device orientation, the system calls this method on the root view controller or the topmost presented view controller that fills the window. If the view controller supports the new orientation, the window and view controller are rotated to the new orientation. This method is only called if the view controller's shouldAutorotate method returns YES.

Override this method to report all of the orientations that the view controller supports. The default values for a view controller's supported interface orientations is set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom.

The system intersects the view controller's supported orientations with the app's supported orientations (as determined by the Info.plist file or the app delegate's application:supportedInterfaceOrientationsForWindow: method) to determine whether to rotate.

Community
  • 1
  • 1
carantes
  • 197
  • 1
  • 9