UIActionSheet cancelButtonTitle ipad

发布于 2024-10-15 01:51:44 字数 897 浏览 2 评论 0原文

我正在使用 UIActionSheet 向用户呈现一组选择。它在 iPhone 和 iPod Touch 上运行良好,但在 iPad 上“取消”选项始终隐藏。也就是说,出现了带有选项的“对话框”,但缺少“取消”按钮。

代码如下:

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

UIActionSheet 文档 状态:

取消按钮标题: 取消按钮的标题。该按钮会自动添加到操作表中,并分配一个适当的索引,该索引可从 cancelButtonIndex 属性获得。该按钮显示为黑色,表示它代表取消操作。如果您不需要取消按钮或在 iPad 上显示操作表,请指定 nil。

我没有通过零,所以我不清楚发生了什么。这是一个错误吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遇到 2024-10-22 01:51:44

这可能取决于您呈现 UIActionSheet 的方式,但请记住,点击 UIActionSheet 外部是 iPad 上的取消按钮。

虽然可能有其他方法来呈现 UIActionSheet,但默认情况下您将无法使用取消按钮。

编辑:

根据另一个非常类似的答案问题,您可以使用以下代码使取消按钮在 iOS 4.2 及更早版本上出现。请注意,在 iOS 4.2.1 中,这似乎已更改并且不再起作用。

actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

或者这个:

actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文