在演示文稿正在进行时尝试显示UIAlertController

时间:2017-02-10 05:50:28

标签: ios swift3 xcode8 uialertcontroller

我在后台线程中做请求,得到响应后我试图在主线程上显示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)
    }
}

0 个答案:

没有答案