我在我的swift project
中使用UIAlertView
来显示正在执行的消息/当前操作,这发生在网络事务正在发生时。当我收到来自API端点的成功响应时,我想关闭UIAlertView
。以无编程方式关闭UIAlertview
有什么方法可以关闭当前显示的报警programatically
或不使用计时器。
我在我的swift project
中使用UIAlertView
来显示正在执行的消息/当前操作,这发生在网络事务正在发生时。当我收到来自API端点的成功响应时,我想关闭UIAlertView
。以无编程方式关闭UIAlertview
有什么方法可以关闭当前显示的报警programatically
或不使用计时器。
在全球范围内设置提醒的名字,并添加以下行,当你得到的回应,这将使警报消失
alert.dismissWithClickedButtonIndex(0, animated: true)
这里是我的问题
答案声明UIAlertview
全球
let alert : UIAlertView = UIAlertView()
在我开始网络转换之前,写下面的代码块:
alert = UIAlertView(title: "MyAlert", message: "Message Body", delegate: self, cancelButtonTitle: nil, otherButtonTitles: nil,nil)
alert.show()
获得成功的响应后,解雇UIAlertView中:
alert.dismissWithClickedButtonIndex(0, animated: true)