2014-03-26 106 views
-3

我在建立登錄/註冊頁面,它的工作非常完美。忘記密碼/用戶名Xcode

但我只是想知道如何在登錄頁面上爲「忘記我的密碼或用戶名」添加標籤或按鈕。

  • 我想有一個彈出消息或警報,讓用戶輸入自己的電子郵件
    • 所以如果他們的電子郵件不存在於數據庫中有會彈出一個消息,說,這封電子郵件是不正確的或什麼
    • 萬一電子郵件已經存在於數據庫中我想發送用戶名和一個新的密碼給用戶。

請注意,我用的解析。

謝謝

+0

請注意,這已與'的Xcode IDE'無關 – Popeye

+0

默認登錄頁面已經有「忘記?」鏈接提供您想要的功能。你爲什麼不使用它? Parse還提供了有關如何自定義登錄頁面的示例。 – Moonwalkr

回答

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

    } 
+0

真的非常感謝這項工作,只是另外一個問題。我如何發送通知郵件給用戶? – Lolieta

+0

parse.com最棒的地方在於,每次用戶更改或重置密碼的請求時,parse.com服務器都會自動發送電子郵件以驗證或重置密碼 – savana