iphone - iPad 上的操作表不显示“取消”按钮

标签 iphone ipad uiactionsheet

在 iPhone 上,此代码显示取消按钮:

- (IBAction)buttonPressed
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:@"Are you sure?"
                                  delegate:self 
                                  cancelButtonTitle:@"No way!"
                                  destructiveButtonTitle:@"Yes, I'm sure!"
                                  otherButtonTitles:nil];
    [actionSheet showInView:self.view];
    [actionSheet release];  
}

但在 iPad 上,只显示破坏性按钮。
有什么问题吗?

最佳答案

这是 UI design and guidlines 的一部分。在“行动表”下,他们说:

Do not include a Cancel button, because people can tap outside the popover to dismiss the action sheet without selecting one of the other alternatives.

看起来像 SDK hide the button for you on purpose 。我不确定是否有解决方案,但也许您可以添加自己的按钮并设置 cancelButtonIndex 进行匹配。或者您可以切换到 UIAlertView

关于iphone - iPad 上的操作表不显示“取消”按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2760545/

相关文章:

iphone - 迭代充满日期的 NSArray 并与另一个 NSArray 进行比较

iphone - 如何检查 iOS 设备是否设置为 "do not disturb"?

ios - 是否可以编辑 UIAlertAction 标题字体大小和样式?

ios - UIActionSheet iOS 8 错误

ios - NSOperationQueue mainQueue vs performSelectorOnMainThread?

iphone - 将选中的项目保存在 TableView 中,以便以后在 iPhone 中重复使用

iphone - 如果该应用程序是通用的,为什么我不能在App Store中看到我的iPad版本的应用程序?

iphone - Xcode,只检索带有字母 A 的地址簿姓氏(依此类推)

iphone - UIActionSheet 委托(delegate)方法不会被调用

iphone - 如何正确设计多方向 iPad 应用程序