Ian*_*Ian 4 uiactionsheet ipad ios ios7 swift
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)
Run Code Online (Sandbox Code Playgroud)

我能够通过避免默认的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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
900 次 |
| 最近记录: |