gpt4 book ai didi

ios - AlertController - 与 UIViewController 冲突

转载 作者:行者123 更新时间:2023-11-30 13:27:38 25 4
gpt4 key购买 nike

我正在使用 Swift 开发一个 iOS 项目。我有简单的登录/注册/丢失密码 View Controller ,以使用 Firebase 实现安全性。问题出在重置密码 View Controller 上。如果用户单击它,它们将被发送(以模式方式呈现)到丢失密码 View Controller 。

当前代码的问题是,当 Firebase 找到输入的电子邮件并发送密码重置电子邮件时,我会显示警报 Controller 以供用户确认。问题是,当我在警报 Controller 上单击“确定”时,我希望重置密码 View Controller 也被关闭。不知道为什么它现在不起作用。我确实收到了电子邮件,但是当我单击警报 Controller 上的“确定”按钮时,它只会关闭警报 Controller ,并且 self.dismissViewControllerAnimated(true,completion: nil) 似乎不会关闭模态提出了重置密码 View Controller 。

我尝试使用self.dismissViewController(true,completion:nil)以及self.performSegueWithIdentifier(“goToLoginVC”,sender:nil)。 Non 似乎有效,但我不明白为什么。

这是函数本身:

    @IBAction func resetPasswordPressed(sender: AnyObject) {

let email = emailTextField.text

if email != "" {

DataService.ds.REF_BASE.resetPasswordForUser(email, withCompletionBlock: { error in

if error != nil {

// Error - Unidentified Email
showAlert(title: "Unidentified Email Address", msg: "Please, re-enter the email you have registered with.", actionButton: "OK", viewController: self)

} else {

// Success - Sent recovery email

let alertController = UIAlertController(title: "Email Sent", message: "An email has been sent. Please, check your email now.", preferredStyle: UIAlertControllerStyle.Alert)
let okAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(okAction)
self.presentViewController(alertController, animated: true, completion: nil)

self.dismissViewControllerAnimated(true, completion: nil)
}

})

} else {

showAlert(title: "Error!", msg: "Email is required in order to reset your password. Please, enter your email. ", actionButton: "OK", viewController: self)
}
}

最佳答案

这样做:

alertController.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle. Default, handler: { action in

//Add your logic here

}))

关于ios - AlertController - 与 UIViewController 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36967569/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com