Search code examples
iphoneiosios6rotationuialertview

iOS 6: UIAlertView rotation issue


I have an app that works in all directions.

For iOS 6 I use

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

And for iOS 5

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

This part seems to work.

Then, because I want to stop the rotation animation, I implement these methods:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

    [UIView setAnimationsEnabled:NO];
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];

    [UIView setAnimationsEnabled:YES];
}

Everything is OK, but if I show an UIAlert and then the device rotates, the background black shadows appears in the wrong direction.

Screenshot

This happens only in iOS 6 and not on iOS 5, on the actual device and in the simulator, and only if I prevent the rotation from animating.

Any idea?

EDIT: Here my rootViewController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Other things

    self.rootViewController = [[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]] autorelease];
    self.window.rootViewController = self.rootViewController;
    [self.window makeKeyAndVisible];

    return YES;
}

Window is stored in NIB.


Solution

  • To close this question...

    I don't know what was the problem causing this issue, I suppose something related to iOS version.

    I solved it by implementing my custom alert (a subclass of UIViewController).