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

 好白菜1 发布于 2022-12-10 11:24

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)

在iOS 7和8上比较UIActionSheet实例

1 个回答
  • 我能够通过避免默认的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)
    

    2022-12-11 02:57 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有