Ever noticed an app where the UIActionSheet’s bottom button doesn’t want to respond to your taps, unless you hit exactly in the top of the button? If you have a UITabBarController and want to display a UIActionSheet, you have to be careful with what view you show the UIActionSheet in.
If a UIActionSheet is shown in “self” or “self.view” and you got a UITabBarController behind it less than half of the last button will respond to taps:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"UIActionSheet Title" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Option 1", @"Option 2", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[actionSheet showInView:self];
[actionSheet release];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[actionSheet showInView:self];
[actionSheet release];
Here’s how much of the button will actually respond to taps:

Here’s what you need to do to fix it:
[actionSheet showInView:[[[UIApplication sharedApplication] windows] objectAtIndex:0]];
And what it does:

I think showFromToolbar: is what you’re looking for.
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIActionSheet_Class/Reference/Reference.html#//apple_ref/occ/instm/UIActionSheet/showFromToolbar:
I have come across weird animation behaviour when using this method (dropping down from the top), so have found this approach to work better.
You safe my day, thanks a lot! =)
Thank you so much, you save my day
This is a good solution but not perfect. If you need to use device rotation you will have issues with action screen.
In UIDeviceOrientationPortraitUpsideDown state action view will be shown upside down.
[actionsheet showInView:self.tabBarController.view];
this is how I use it in my apps, no problems.
Nik’s answer saved the day. I noticed the upsidedown issue and was looking for another way to display the actionsheet correctly.
[actionsheet showInView:self.tabBarController.view] did the tricky
actually:
myActionSheet.ShowInView(this.TabBarController.View);
since i’m using monotouch, but you get the point :)
thanks