我在我的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)