I have a UIBarButtonItem opening an action sheet to offer users choices about what to do. Everything works as expected unless I try to click on the "Cancel" button. The target of the button appears to have moved up from where it should be. I can only activate it by clicking somewhere in the middle of the "Cancel" and "Ok" buttons.
I've tried at action sheets in other applications and they work fine, so it's not just my big thumb. The action sheet is opening in a UIViewController
- (void)showOpenOptions
{
UIActionSheet *sheet = [[UIActionSheet alloc]
initWithTitle:NSLocalizedString(@"Open link in external application?", @"Open in external application")
delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", @"Cancel")
destructiveButtonTitle:NSLocalizedString(@"Open Link", @"Open Link")
otherButtonTitles:nil];
[sheet showInView:self.view];
[sheet release];
}
Best Answer
Instead of passing the current view controller's view to the action sheet, use the
showFromTabBar:
method ofUIActionSheet
.The Right Way
This will give the correct tappable area:
The Wrong Way
This will put the tappable area in the wrong place (if you're using a tab bar or toolbar):
If you're using a toolbar, use the
showFromToolbar:
method instead. You'll need a reference to the toolbar, most likely an ivarMy Old Answer Also works, but is hacky:
Just found a possible answer:
http://openradar.appspot.com/6410780
Edit: It works correctly when I change the view to be the tab bar's view