ios UIActionSheet cancel button doesn't work right
Asked Answered
A

3

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

Allyn answered 14/7, 2011 at 21:5 Comment(1)
It's an answer: #1198246Piddle
C
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.

Companionable answered 14/7, 2011 at 21:10 Comment(1)
thank you! it was exactly!I use showFromTabBar instead of showInView and now is ok!Allyn
E
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 :)

Emmeram answered 13/9, 2013 at 21:33 Comment(0)
B
2

use

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

instead of

[actionSheet showInView:self.view];
Bethina answered 22/8, 2013 at 10:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.