ios - 是否可以将工具栏添加到 UIAlertController,以及使用 Swift 将按钮添加到行?

标签 ios swift uialertcontroller

我有一个使用 .xib 文件构建的自定义 subview ,以充当 UIActionSheet(我知道它已被弃用,取而代之的是 UIAlertController). subview 如下所示:

enter image description here

我想做的是将此 subview 重建为 UIAlertController。我的问题是,是否可以将 UIToolbar 添加到 UIAlertController 的顶部,如下图所示,并且可以将按钮添加到每个选项的每一行的任一侧( +/- 符号是按钮)。我对重新设计不感兴趣,但是,我想使用具有相同功能的 UIAlertController 重新实现它。这可能吗?有例子吗?

最佳答案

简短的回答是 -
根据 UIAlertController Class Reference - 您只能向警报添加文本字段。

func addTextFieldWithConfigurationHandler(_ configurationHandler: ((UITextField) -> Void)?)  

Calling this method adds an editable text field to the alert. You can call this method more than once to add additional text fields. The text fields are stacked in the resulting alert.

关于ios - 是否可以将工具栏添加到 UIAlertController,以及使用 Swift 将按钮添加到行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38446450/

相关文章:

ios - ios中的唯一标识

ios - Swift 数组差异

iOS 在 swift 主 StoryBoard 之前创建一个欢迎页面

ios - 警告时 UIAlertController : 0x7ff211650140 called in Swift

ios - 动画饼图填充模式?

iphone - 图像映射不适用于 iOS 设备,大图像会被设备重新缩放

ios - UNCalendarNotificationTrigger 不适用于完整的日期组件

swift - 使用 Swift 更改 NSMenuItem 标题

ios - 带有白色边框的 alertController

swift - 关闭 UIAlertController UITextField 上的键盘