开发者

UIActionSheet cancelButtonTitle ipad

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 t开发者_开发问答he 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?


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜