I need to display a UIAlertView in landscape mode. I tried the obvious, setting the transform in the willPresentAlertView: delegate method to no avail:
I was struggling with quite the same issue lately. For me solution was using UIAlertController - cover older handling of UIAlertview and UIActionsheet.
UIAlertController, where you must overloaded methods viewWillAppear and viewWillDisappear, like in example bellow.AlertViewController.h
#import
@interface AlertViewController : UIAlertController
@end
AlertViewController.m
#import "AlertViewController.h"
@interface AlertViewController ()
@end
@implementation AlertViewController
- (void) viewWillAppear:(BOOL)animated {
[self.view setTransform:CGAffineTransformMakeRotation(M_PI_2)];
}
- (void) viewWillDisappear:(BOOL)animated {
[self.view setHidden:YES];
}
...
implement method for showing alert view where you needed.
(void) showInfoAlertView {
AlertViewController *alert = [AlertViewController alertControllerWithTitle:@"My Alert" message:@"This is an alert." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:ok];
[self presentViewController:alert animated:NO completion:nil];
}