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)
最佳答案
我能够通过避免使用默认的 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/