1
votes

I'm using UIActionSheet to present a set of choices to the user. It works fine on iPhone and iPod Touch, but on the iPad the "cancel" option is always hidden. That is, the "dialog box" with the options appears, but the "cancel" button is missing.

Here's the code:

self.popupQuery = [[[UIActionSheet alloc] initWithTitle:title
                                               delegate:self
                                      cancelButtonTitle:cancelButtonTitle
                                 destructiveButtonTitle:nil
                                      otherButtonTitles:option0, option1, cancelButtonTitle, nil] autorelease];

The UIActionSheet docs state:

cancelButtonTitle: The title of the cancel button. This button is added to the action sheet automatically and assigned an appropriate index, which is available from the cancelButtonIndex property. This button is displayed in black to indicate that it represents the cancel action. Specify nil if you do not want a cancel button or are presenting the action sheet on an iPad.

I'm not passing nil, so I'm not clear what's going on. Is this a bug?

1
what is the value of "cancelButtonTitle"? If it is nil, then the button will not show.WrightsCS

1 Answers

6
votes

It might depend on how you are presenting your UIActionSheet, but bear in mind that tapping outside the UIActionSheet is the cancel button on the iPad.

While there may be an alternative way to present the UIActionSheet, the default will leave you with out that cancel button.

EDIT:

According to another answer on a very similar question, you can make the cancel button appear on iOS 4.2 and prior by using the following code. Note that in iOS 4.2.1, this seems to have been changed and will no longer work.

actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

or this:

actionSheet.actionSheetStyle = UIActionSheetStyleDefault;