我正在开发一个应用程序,我想知道如何在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 :(得分:1)
只需将委托MFMessageComposeViewControllerDelegate
添加到.h文件中,然后在要发送电子邮件时使用此代码,并在项目中添加框架MessageUI.framework
-(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];
}
}
这个贝娄方法是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网络服务发送电子邮件
我希望这可以帮助你...