Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios UIActionSheet cancel button doesn't work right

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:)

like image 398
ghiboz Avatar asked Jul 14 '11 21:07

ghiboz


3 Answers

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.

like image 123
PengOne Avatar answered Nov 01 '22 11:11

PengOne


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 :)

like image 44
Ajay Chaudhary Avatar answered Nov 01 '22 09:11

Ajay Chaudhary


use

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

instead of

[actionSheet showInView:self.view];
like image 2
Amitabha Avatar answered Nov 01 '22 09:11

Amitabha