我在后台线程中做请求,得到响应后我试图在主线程上显示UIAlertController
。但有一段时间它没有显示UIAlertController
。
这是我的代码
func showAlertMessage() -> Void {
DispatchQueue.main.async {
let alertController = UIAlertController(title: kSuccess, message: kSuccessfullyLoggedOut, preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "OK", style: .cancel) { (action :UIAlertAction) in
DispatchQueue.main.async {
self.dismiss(animated: true, completion: nil)
}
}
alertController.addAction(cancelAction)
self.present(alertController, animated: true, completion: nil)
}
}