Search code examples
objective-ccocoa-touchuialertviewcgaffinetransform

Forcing UIAlertView into landscape mode


I need to display a UIAlertView in landscape mode. I tried the obvious, setting the transform in the willPresentAlertView: delegate method to no avail:

-(void) willPresentAlertView:(UIAlertView *)alertView {

    alertView.transform = CGAffineTransformMakeRotation(M_PI_2);
}

Any suggestions on how to fix this?


Solution

  • Have you tried in the didPresentAlertView?

    - (void)didPresentAlertView:(UIAlertView *)alertView
    {
        // UIAlertView in landscape mode
        [UIView beginAnimations:@"" context:nil];
        [UIView setAnimationDuration:0.1];
        alertView.transform = CGAffineTransformRotate(alertView.transform, 3.14159/2);
        [UIView commitAnimations];
    }