Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotating a UIAlertView

I've created a custom UIAlertView (by subclassing it and messing around with its show function) that has some custom subviews and is of non-standard size.

It works ok when I create and display it, however, when the device is rotated, the alert rotates and then returns to its default size.

Any ideas what functions to override - or should I tweak the UIViewController?

thanks, Peter

like image 954
Peter Sarnowski Avatar asked Jul 28 '11 13:07

Peter Sarnowski


1 Answers

Not sure if force rotating the UIAlertView fits the Apple GUI guidelines, but you can rotate it by defining the status bar (status bar and UIAlertView sticks together)

application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
application.statusBarOrientation = UIInterfaceOrientationLandscapeLeft;

But UIAlertView is a UIView just like many others, so try this :

- (void)didPresentAlertView:(UIAlertView *)alertView
{
    [UIView beginAnimations:@"" context:nil];
    [UIView setAnimationDuration:0.1];
    alertView.transform = CGAffineTransformRotate(alertView.transform, degreesToRadian(90));
    [UIView commitAnimations];
}
like image 153
Nils Munch Avatar answered Sep 19 '22 14:09

Nils Munch