I read a lot about that. People say it will not autorotate whene its parent is not set to auto rotate. I tried everything but no luck. I created view-based app (v4.2) with a button that executes this:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive Button" otherButtonTitles:@"Other Button 1", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet showInView:self.view];
The root controller is set to auto-rotate. The actionSheet does not. Note that when I rotate the simulator none of the root controller's orientation methods are called. Is there a problem with the delegate? What is wrong?
Well, here's my solution to this problem:
Basically what we do is:
for example:
@interface ViewController ()
{
UIActionSheet *_sheet;
BOOL _isClicked;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (IBAction)click:(id)sender
{
_isClicked = YES;
[self showActionSheet];
}
- (void)didRotate:(NSNotification *)note
{
[_sheet dismissWithClickedButtonIndex:1 animated:YES];
[self performSelector:@selector(showActionSheet) withObject:nil afterDelay:1.0];
}
- (void)showActionSheet
{
if (!_isClicked) return;
_sheet = [[UIActionSheet alloc] initWithTitle:@"title" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"new" otherButtonTitles:@"bla", nil];
[_sheet showInView:self.view];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With