ios - 我可以向 UIAlertController 添加开关吗?

标签 ios swift uialertcontroller

我的UIAlertController调用代码。我需要将开关添加到警报 View 。

let alertController = UIAlertController(title: "Поздравляем!", message: "Ваш комментарий сохранен! Если хотите изменить его, выключите и включите переключатель Комментария!", preferredStyle: UIAlertControllerStyle.alert)

let okAction = UIAlertAction(title: "Окей", style: .default) { (action) -> Void in
    let sb = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "mailVerify")
    self.present(sb, animated: true, completion: nil)
}

alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)

最佳答案

一种可能的方法是使用 switch 创建自定义 UIView 并以模态方式呈现它而不是 UIAlertController。或者试试这个 Switch in UIAlert Controller programatically

关于ios - 我可以向 UIAlertController 添加开关吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44160798/

相关文章:

ios - 警告 : UIAlertController is already presenting

ios - 无法摆脱致命异常 : NSInternalInconsistencyException Error

swift - 使用 ObjectIdentifier() 和 '===' 运算符的区别

ios - Firebase 云消息传递通知不发送 iOS 负载格式

ios - UIAlertController 作为 subview Controller

ios - 如何在 ObjC 中普遍更改 UIAlertController 按钮颜色

ios - 使用 Azure 总线服务队列在 iOS 设备和后端之间代理消息传输

iphone - 如何在 iPhone 中解析 xml,

ios - 带有自定义字体的 UITextField secureTextEntry 项目符号?

swift - 如何在 Swift 中使用 DispatchQueue 循环遍历 Alamofire 请求后收到通知?