ios - UIActionsheet 不显示运行 iOS7 的 iPad 上的所有按钮

标签 ios ipad ios7 swift uiactionsheet

UIActionSheet 实例无法在运行 iOS7 的 iPad 上正确显示。出于某种原因,他们显示取消按钮并离开最后一个按钮。相同的代码在 iOS8 上运行良好。

您可能希望忽略取消按钮,因为点击屏幕上的其他地方将关闭操作表。有谁知道为什么会这样?

两种情况下使用完全相同的代码:

// Create UIActionSheet    
let mapOptions = UIActionSheet(title: "Select map type", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles: "Standard", "Hybrid", "Satellite")

// Display from bar button
mapOptions.showFromBarButtonItem(self.mapTypeButton, animated: true)

comparison of UIActionSheet instances on iOS 7 and 8

最佳答案

我能够通过避免使用默认的 UIActionSheet 构造函数并单独添加按钮来解决问题。这 - 并确保最后添加取消按钮 - 解决了这个问题。

// Create the UIActionSheet
var mapOptions = UIActionSheet()
mapOptions.title = "Select map type"
mapOptions.addButtonWithTitle("Standard")
mapOptions.addButtonWithTitle("Hybrid")
mapOptions.addButtonWithTitle("Satellite")

// Add a cancel button, and set the button index at the same time
mapOptions.cancelButtonIndex = mapOptions.addButtonWithTitle("Cancel")
mapOptions.delegate = self

// Display the action sheet
mapOptions.showFromBarButtonItem(self.mapTypeButton, animated: true)

关于ios - UIActionsheet 不显示运行 iOS7 的 iPad 上的所有按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27060164/

相关文章:

ios - 限制用户在 TextView 中输入滥用词

iphone - 如何使带有触摸的 UIImageView 转到其他 ViewController?

objective-c - 在 Restkit iOS 中解析没有对象映射的 JSON

ios7 - 通过 cocoapods 更新 KIF 框架后运行以及测试 Xcode 工作区时出现链接器错误

ios - 单击按钮滚动 UIScrollView

iphone - 在 AFNetworking 中取消批处理请求

swift - 为什么自定义表格单元格总是默认大小

android - Owl Carousel 在移动 ios/android 上快速滚动时启用拖动

ios - 将元数据添加到我的应用内购买 ios

iphone - 在 iOS 上实现 "user to user"VoIP 的最佳方式