简体   繁体   English

忘记密码/用户名 Xcode

[英]forgot password/username Xcode

I am building login/signup pages and it's work so perfectly.我正在构建登录/注册页面,它的工作非常完美。

But I just want to know how I can add a label or a button for the "Forgot my password or username" on the login page.但我只想知道如何在登录页面上为“忘记密码或用户名”添加标签或按钮。

  • I'd like to have a pop up message or an alert that allows the user to enter their Email我想要一条弹出消息或警报,允许用户输入他们的电子邮件
    • so in case their Email doesn't exist in the database there will pop a message that says, that this email is not correct or something因此,如果他们的电子邮件不存在于数据库中,则会弹出一条消息,指出该电子邮件不正确或其他内容
    • in case the email already exists in the database I want to send the username and a new password to the user.如果电子邮件已存在于数据库中,我想向用户发送用户名和新密码。

Please note that I am using parse.请注意,我正在使用解析。

Thank you,谢谢,

First display an alert view with type UIAlertViewStylePlainTextInput首先显示一个类型为 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];

and in your alert view delegate并在您的警报视图委托中

 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];
        }];

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM