2014-04-13 2 views
1

사용자가 비밀번호를 재설정 할 수있는 기능을 구현하고 싶습니다. 이미 경고보기를 표시하고 이메일을 요청하는 버튼을 만들었지 만 확인을 누르면 이메일을 보내지 않습니다.재설정 구문 분석 기능을 사용하여 iOS 용 구문 분석

어떻게해야합니까? 어디 경고보기 위임 방법은

-(IBAction)forget:(id)sender { 

    [PFUser requestPasswordResetForEmailInBackground:@"[email protected]"]; 

    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

입니까? –

+1

사용자에게 이메일을 요청하기 전에 비밀번호를 재설정하는 것처럼 보입니다. – Rich

답변

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

좋은 답변이지만 alertView의 코드와 관련된 주요 문제 : clickedButtonAtIndex : "취소"또는 "확인"여부에 관계없이 트리거합니다. 조건부를 추가해야합니다 ... –

+0

죄송합니다, 그걸 보지 못했습니다, 고마워요! –

+0

문제 없습니다. 좋은 대답. :) –