Change or disable the iPhone rotating animation when orientation changes

Aldrich Co picture Aldrich Co · Apr 29, 2010 · Viewed 9.6k times · Source

How do I change or disable the rotating animation when screen orientation changes from landscape to portrait, or vice versa?

Answer

Nils Munch picture Nils Munch · Jun 9, 2011

Yes, it is possible to disable the animation, without breaking everything apart.

The following codes will disable the "black box" rotation animation, without messing with other animations or orientation code:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    [UIView setAnimationsEnabled:YES];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    [UIView setAnimationsEnabled:NO];
  /* Your original orientation booleans*/
}

Place it in your UIViewController and all should be well. Same method can be applied to any undesired animation in iOS.

Best of luck with your project.