在swift中使用解析重置密码
好的,那么我怎样才能访问添加块末尾的“textField”呢?我尝试创建一个名为“alertTextField”的全局属性,然后将其设置为块中的textField,以便我可以在其他操作中访问它,但它似乎不起作用。有什么建议吗 谢谢大家!在swift中使用解析重置密码,swift,parse-platform,uialertcontroller,Swift,Parse Platform,Uialertcontroller,好的,那么我怎样才能访问添加块末尾的“textField”呢?我尝试创建一个名为“alertTextField”的全局属性,然后将其设置为块中的textField,以便我可以在其他操作中访问它,但它似乎不起作用。有什么建议吗 谢谢大家! @IBAction func resendPassword(sender: AnyObject) { let alertController : UIAlertController = UIAlertController(title: "Forgo
@IBAction func resendPassword(sender: AnyObject) {
let alertController : UIAlertController = UIAlertController(title: "Forgot Password?", message: "Enter your email", preferredStyle: UIAlertControllerStyle.Alert)
let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
}
alertController.addAction(cancelAction)
alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in
textField == self.alertTextField
textField.delegate = self
textField.placeholder = "Email"
}
let sendAction: UIAlertAction = UIAlertAction(title: "Send", style: UIAlertActionStyle.Default) { action -> Void in
if (self.alertTextField?.text != nil) {
PFUser.requestPasswordResetForEmailInBackground(self.alertTextField!.text)
}
}
alertController.addAction(sendAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
有关详细信息,请查看此处的示例代码:
@如何接受答案
@IBAction func resendPassword(sender: AnyObject) {
let alertController : UIAlertController = UIAlertController(title: "Forgot Password?", message: "Enter your email", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in
textField.placeholder = "Email"
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
alertController.addAction(cancelAction)
let sendAction = UIAlertAction(title: "Send", style: UIAlertActionStyle.Default) { _ in
// below is how you access the textField
let emailTextField = alertController.textFields![0] as UITextField
if let email = emailTextField.text {
PFUser.requestPasswordResetForEmailInBackground(email)
}
}
alertController.addAction(sendAction)
self.presentViewController(alertController, animated: true, completion: nil)
}