13

I have this problem: here is my code:

UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Share the race" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Send with mail" otherButtonTitles:nil];
    popupQuery.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    [popupQuery showInView:self.view];
    [popupQuery release];

and everything seems ok, the 2 buttons are showed right, the "send with mail" button is ok, but the cancel catch the click only on the upper side... here a shot that illustrate the situation:

error click!

how can I solve this?

thanks:)

PengOne
  • 48,188
  • 17
  • 130
  • 149
ghiboz
  • 7,863
  • 21
  • 85
  • 131

3 Answers3

37

My guess is that the bottom portion of the UIActionSheet extends beyond the bounds of the view, and so doesn't respond to touches.

To test this theory, add another button and see if all upper buttons work fine but the bottom button still exhibits this behavior.

To fix this problem, make sure the view extends to the bottom of the screen. If you have a tabBar in your app, that's going to be my suspect for the problem. You could use showFromTabBar: if you want the sheet above the tabBar, or showFromToolbar: to show it from a toolBar.

If you don't have a bottom bar, then I'm wrong and have no idea.

PengOne
  • 48,188
  • 17
  • 130
  • 149
7

You should show the action sheet as a subview of the application window, not of the current view.

UIActionSheet *actionSheet = [[UIActionSheet alloc] init...];

// ...

[actionSheet showInView:[UIApplication sharedApplication].keyWindow];

May be it will help others.

Happy Coding :)

Ajay Chaudhary
  • 1,993
  • 15
  • 23
2

use

[actionSheet showFromTabBar:[[self tabBarController] tabBar]];

instead of

[actionSheet showInView:self.view];
Amitabha
  • 1,664
  • 1
  • 12
  • 30