Hi,
I am trying to display a UIActionsheet in my application. It works perfectly in portrait mode but when I try to have it display in a landscape orientation it still slides in from the bottom. However it no longer uses buttons and displays with the picker control like it is in landscape mode. Its just in the wrong position.
I don't use auto rotation and keep everything in portrait mode. Occasionally I am displaying things in a landscape mode and would like the actionsheet to appear properly.
I am setting the status bar orientation like so...
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
When I'm in 'landscape mode', and the status bar always appears correctly. If i display an AlertView it also displays correctly. I am then displaying the actionsheet like this
UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:nil otherButtonTitles: @"button", nil];
as.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[as showInView:self.view];
//[as showFromToolbar:toolbar];
I have also tried to display it from the app delegate and toolbar. If I set the statusbar orientation just before displaying it still doesn't work. I have even tried.
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
Does anyone has any idea why the actionsheet could be displaying in the wrong position yet with the right controls? Or how to force the actionsheet to display in a particular position. I would rather not have to implement my own version of an actionsheet to have it display right.
Thanks in advance.
Edit / Solution: Force Action sheet to show in landscape mode
Here is how i managed to get it to work, i created a landscape view and added it to my main window like so:
landscapeView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 480)];
landscapeView.transform = CGAffineTransformMakeRotation((-1)*M_PI/2);
landscapeView.bounds = CGRectMake(0, 0, 480, 380);
[appDelegate.window addSubview:landscapeView];
and then displayed my action sheet like this
if (landscape) {
[menu showInView:landscapeView];
} else {
[menu showInView:self.view];
}
Much thanks to tc. for pointing me in the right direction here.