0

I have an app with all screens in portrait except for one. In iOS 8 that one landscape page appears fine, until the device gets rotated in any direction. The view rotates on a weird axis and parts of it go off screen. I've tried updating the frame of the view in viewWillTransitionToSize, but it just causes even more issues, changing the frames of subviews to be super crazy. Some solutions have suggested doing this:

- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification
{
    [UIViewController attemptRotationToDeviceOrientation];
}

But that didn't work for me. Any ideas? Thanks!

CodyMace
  • 646
  • 1
  • 8
  • 19
  • Does it work on iOS7? – Rory McKinnel Mar 26 '15 at 23:31
  • 1
    Have a look at this in case it is your issue as it affects rotation on iOS8: http://stackoverflow.com/questions/28443852/uisplitviewcontroller-rotation-ios8-not-working-as-expected/28443948#28443948 – Rory McKinnel Mar 26 '15 at 23:33
  • Yeah @RoryMcKinnel, that seems to be the fix. Is it a for sure thing that removing that line won't cause any other issues on any iOS version? This app needs to run on iOS7 and 8. – CodyMace Mar 27 '15 at 15:08
  • 1
    It will all be fine. It is a hangover from building with xcode pre xcode6 and is no longer needed. Shame Apple did not think to at least put in a warning. I took mine out and so far all is well in iOS7 and 8. – Rory McKinnel Mar 27 '15 at 16:32

2 Answers2

2

The offending line will be in your AppDelegate didFinishLaunchingWithOptions function and looks like the following:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

Ravikanth
  • 308
  • 1
  • 10
  • Commenting that line out seems to work. But will it cause issues on iOS 7 or any other issues throughout the app? – CodyMace Mar 27 '15 at 14:24
0

Please try this.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

This will allowed for both left and right landscape (but it deprecated since iOS6).

Or this one but I'm not test it.

- (BOOL)shouldAutorotate {
    return NO;
}
  • Neither of these seem to work, probably because of the way iOS 8 handles rotation now. Thanks though. – CodyMace Mar 27 '15 at 14:25