ios – 如何在Xcode中的应用程序内发送电子邮件?

ios – 如何在Xcode中的应用程序内发送电子邮件?,第1张

概述我是 xcode的新手,我想知道如何在应用程序中发送电子邮件!我的代码如下,但我不断收到错误“没有可见@interface for’jakem’声明选择器’presentViewControllerAnimated:’”.我的代码完全错了吗?或者我只是忘记声明选择器,我如何声明选择器?我已经在互联网上研究了至少一个小时,但没有任何工作.有人请帮帮我! -(IBAction)sendEmail{ 我是 xcode的新手,我想知道如何在应用程序中发送电子邮件!我的代码如下,但我不断收到错误“没有可见@interface for’jakem’声明选择器’presentVIEwControllerAnimated:’”.我的代码完全错了吗?或者我只是忘记声明选择器,我如何声明选择器?我已经在互联网上研究了至少一个小时,但没有任何工作.有人请帮帮我!

-(IBAction)sendEmail{    MFMailComposeVIEwController *composer = [[MFMailComposeVIEwController alloc] init];    [composer setMailComposeDelegate:self];    if ([MFMailComposeVIEwController canSendMail]) {    [composer setToRecipIEnts:[NSArray          arrayWithObjects:@"FrankMurphy.CEO@RomansXIII.com",nil]];    [composer setModalTransitionStyle:UIModalTransitionStyleCrossdissolve];    [self presentVIEwController:composer animated:YES];    }    }    -(voID)mailComposeController:(MFMailComposeVIEwController *)controller   dIDFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {    if(error) {    UIAlertVIEw *alert = [[UIAlertVIEw alloc] initWithTitle:@"error" message:[Nsstring    stringWithFormat:@"error %@",[error description]] delegate:nil cancelbuttonTitle:@"dismiss" otherbuttonTitles:nil,nil];    [alert show];    [self dismissVIEwControllerAnimated:YES];    }    else {    [self dismissVIEwControllerAnimated:YES];    }    }
解决方法 在.h头文件….

#import <UIKit/UIKit.h>#import <MessageUI/MessageUI.h>@interface SimpleEmailVIEwController : UIVIEwController <MFMailComposeVIEwControllerDelegate> // Add the delegate- (IBAction)showEmail:(ID)sender;@end

在.m实现文件中…..

- (IBAction)showEmail:(ID)sender {// Email SubjectNsstring *emailTitle = @"Test Email";// Email ContentNsstring *messageBody = @"iOS programming is so fun!";// To addressNSArray *toRecipents = [NSArray arrayWithObject:@"info@finetechnosoft.in"];MFMailComposeVIEwController *mc = [[MFMailComposeVIEwController alloc] init];mc.mailComposeDelegate = self;[mc setSubject:emailTitle];[mc setMessageBody:messageBody isHTML:NO];[mc setToRecipIEnts:toRecipents];// Present mail vIEw controller on screen[self presentVIEwController:mc animated:YES completion:NulL];}- (voID) mailComposeController:(MFMailComposeVIEwController *)controller dIDFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{switch (result){    case MFMailComposeResultCancelled:        NSLog(@"Mail cancelled");        break;    case MFMailComposeResultSaved:        NSLog(@"Mail saved");        break;    case MFMailComposeResultSent:        NSLog(@"Mail sent");        break;    case MFMailComposeResultFailed:        NSLog(@"Mail sent failure: %@",[error localizedDescription]);        break;    default:        break;}// Close the Mail Interface[self dismissVIEwControllerAnimated:YES completion:NulL];}
总结

以上是内存溢出为你收集整理的ios – 如何在Xcode中的应用程序内发送电子邮件?全部内容,希望文章能够帮你解决ios – 如何在Xcode中的应用程序内发送电子邮件?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1071749.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存