UIAlertViewcontroller在去视图控制器之前没有被弹出
问题描述:
我想要注册后警报控制器应该弹出,然后去loginFirstViewController但这不会发生,为什么?那就只反而loginfirstviewcontroller坡平了报警控制器UIAlertViewcontroller在去视图控制器之前没有被弹出
if error == nil {
FIRAuth.auth()?.currentUser!.sendEmailVerification(completion: { (error) in
})
print("You have successfully signed up")
//Goes to the Setup page which lets the user take a photo for their profile picture and also chose a username
let alertController = UIAlertController(title: "Successful!", message: "Email Verification link sent", preferredStyle: .alert)
let alertActionOkay = UIAlertAction(title: "Okay", style: .default)
let vc = self.storyboard?.instantiateViewController(withIdentifier: "LoginFirstViewController")
self.present(vc!, animated: true, completion: nil)
alertController.addAction(alertActionOkay)
self.present(alertController, animated: true, completion: nil)
}
答
您直接打开新的视图 - 控制,以防止这一点,你应该添加完成处理程序uialertaction的。当用户按下OK按钮就可以打开其他视图 - 控制
let alertController = UIAlertController(title: "Successful!", message: "Email Verification link sent", preferredStyle: .alert)
let alertActionOkay = UIAlertAction(title: "Okay", style: .default) { (action) in
let vc = self.storyboard?.instantiateViewController(withIdentifier: "LoginFirstViewController")
self.present(vc!, animated: true, completion: nil)
}
alertController.addAction(alertActionOkay)
self.present(alertController, animated: true, completion: nil)
+0
thankyousomuch亲爱的 –
要naviget到另一个VC,如果用户点击OK按钮,否则 –
您的viewController之前的ViewController呈现alertController呈现。您可以尝试在警报推送新视图控制器的好行为时在前一个控制器上显示警报。 –