我想实现一个允许用户重置密码的功能。我已经创建了一个显示警报视图的按钮并询问他们的电子邮件,但是当我点击确定时,它不会发送电子邮件。
我该怎么办?
-(IBAction)forget:(id)sender {
[PFUser requestPasswordResetForEmailInBackground:@"email@example.com"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Email Address" message:@"Enter the email for your account:" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[alertView show];
}
答案 0 :(得分:3)
- (IBAction)forget:(id)sender {
[self getEmail];
}
- (void)getEmail {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Email Address" message:@"Enter the email for your account:" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[alertView show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex != [alertView cancelButtonIndex]) {
UITextField *emailTextField = [alertView textFieldAtIndex:0];
[self sendEmail:emailTextField.text];
}
}
- (void)sendEmail:(NSString *)email{
[PFUser requestPasswordResetForEmailInBackground:email];
}