忘记密码/用户名Xcode

时间:2014-03-26 08:07:24

标签: ios iphone parse-platform

我正在构建登录/注册页面,它的工作非常完美。

但我只是想知道如何在登录页面上为“忘记我的密码或用户名”添加标签或按钮。

  • 我想要一条弹出消息或警告,允许用户输入他们的电子邮件
    • 因此,如果他们的电子邮件在数据库中不存在,则会弹出一条消息,说明此电子邮件不正确或其他
    • 如果电子邮件已存在于数据库中,我想将用户名和新密码发送给用户。

请注意我正在使用解析。

谢谢,

1 个答案:

答案 0 :(得分:0)

首先显示类型为UIAlertViewStylePlainTextInput

的警报视图
  UIAlertView * forgotPassword=[[UIAlertView alloc] initWithTitle:@"Forgot Password"      message:@"Please enter your email id" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
forgotPassword.alertViewStyle=UIAlertViewStylePlainTextInput;
[forgotPassword textFieldAtIndex:0].delegate=self;
[forgotPassword show];

并在警报视图中委托

 if(buttonIndex ==1){
    NSLog(@"ok button clicked in forgot password alert view");
NSString *femailId=[alertView textFieldAtIndex:0].text;
    if ([femailId isEqualToString:@""]) {
        UIAlertView *display;
        display=[[UIAlertView alloc] initWithTitle:@"Email" message:@"Please enter password for resetting password" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
        [display show];

    }else{
        [PFUser requestPasswordResetForEmailInBackground:femailId block:^(BOOL succeeded, NSError *error) {
            UIAlertView *display;
            if(succeeded){
                display=[[UIAlertView alloc] initWithTitle:@"Password email" message:@"Please check your email for resetting the password" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];

            }else{
                display=[[UIAlertView alloc] initWithTitle:@"Email" message:@"Email doesn't exists in our database" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles: nil];
            }
            [display show];
        }];

    }