Search code examples
iosobjective-cios8orientationscreen-orientation

iOS 8 screen rotation messes up view


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!


Solution

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

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