ios - 单击按钮后如何限制警报解除?
问题描述
单击按钮后如何限制警报解除?
let alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert)
// Create the actions
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
UIAlertAction in
NSLog("OK Pressed")
}
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
UIAlertAction in
NSLog("Cancel Pressed")
}
// Add the actions
alertController.addAction(okAction)
alertController.addAction(cancelAction)
// Present the controller
self.presentViewController(alertController, animated: true, completion: nil)
即使我单击 okAction 按钮,是否有限制解除警报?
解决方案
从您的代码中,我根据我的评论对此进行了测试:
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
UIAlertAction in
NSLog("OK Pressed")
DispatchQueue.main.async { () -> Void in
self.testAlert(sender) // Or whatever functionalists that created the alertController
}
}
推荐阅读
- java - Kubernetes 中 Java 应用程序的 Startup-CPU-Limit
- azure - Upload File as a parameter to job in Azure DevOps
- scala - scala:如何在 sbt 中交叉构建库依赖项
- java - 如何连接两个正则表达式以获得实际表达式
- reactjs - 使用 axios 发帖不断返回 Request failed with status code 422
- c# - 如何使用 C# 和 MongoDb 获得自动增量可预测 ID
- php - 使用 PHP CURL 发布 JSON 和文件
- laravel - 为什么我的数据库不更新?(拉拉维尔)
- java - Apache POI自定义数据格式修改
- websocket - 无法使用 rosbridge 建立与 Web 服务器的连接