UIActionSheet cancelButtonTitle ipad
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能取决于您呈现 UIActionSheet 的方式,但请记住,点击 UIActionSheet 外部是 iPad 上的取消按钮。
虽然可能有其他方法来呈现 UIActionSheet,但默认情况下您将无法使用取消按钮。
编辑:
根据另一个非常类似的答案问题,您可以使用以下代码使取消按钮在 iOS 4.2 及更早版本上出现。请注意,在 iOS 4.2.1 中,这似乎已更改并且不再起作用。
或者这个:
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.
or this: