2012-11-26 148 views
1

我正在开发一个应用程序,我想知道如何在iPhone中记住忘记密码的情况。如何在iPhone中忘记密码忘记密码

当用户忘记了自己的密码,然后我在我的应用程序的按钮,当我点击它UIAlertView打开,我有一个文本框,用户必须输入他们的电子邮件地址和密码获得的邮件ID的邮件。

我该怎么办,我有定义按钮这个动作的代码:

-(IBAction)forgetpassword:(id)sender 
{ 
    UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Forget Password" message:@"Please Enter your Email address " delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 
    av.alertViewStyle = UIAlertViewStylePlainTextInput; 
    [av textFieldAtIndex:0].delegate = self; 
    [av show]; 
} 

,但我需要的是只是需要的代码,我可以使用和邮件密码的电子邮件ID哪个用户将输入。

+0

你可以使用SKPSMTPMessage – user1662392

回答

1

只是增加委托MFMessageComposeViewControllerDelegate到.h文件中,然后当你想电子邮件和也在项目

-(IBAction)forgetpassword:(id)sender 
{ 
    if ([MFMailComposeViewController canSendMail]) 
    { 

     MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init]; 
     NSString *mailBody = @"your Message"; 


     [mailComposeViewController setMessageBody:mailBody isHTML:NO]; 
     mailComposeViewController.mailComposeDelegate = self; 
     [self presentViewController:mailComposeViewController animated:YES completion:nil]; 
    } 
    else 
    { 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"e-Mail Sending Alert" 
                 message:@"You can't send a mail" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
     [alert show]; 
     [alert release]; 
    } 
} 

这种波纹管方法添加框架MessageUI.framework使用此代码是MFMessageComposeViewControllerDelegate

委托方法
#pragma mark - MFMessage Delegate 

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result 
{ 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    if (result == MFMailComposeResultSent) 
    { 
     NSLog(@"\n\n Email Sent"); 
    } 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

你也可以使用SKPSMTPmessage网络服务发送电子邮件

我希望这会帮助你...

+0

你能告诉我在哪里添加上面的代码很简单我补充一点,在(IBAction为)忘记方法 – raza

+0

要发送的邮件时,在AlertView的OK按钮用户点击? –

+0

@raza只是删除alertview并在您的忘记密码方法 –