0
好吧,我如何才能在添加它的塊的末尾訪問「textField」?我試圖創建一個名爲「alertTextField」的全局屬性,然後將其設置爲塊中的textField,以便我可以在其他操作中訪問它,但似乎沒有工作。有什麼建議麼?用快速解析來重置密碼
謝謝!
@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)
}
完美!謝謝 – Echizzle
@Echizzle如何接受答案http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work –