ios - 如何使用 MFMailComposeViewController 发送电子邮件

标签 ios

我对 iPhone 开发非常陌生。
在我的应用程序中,我想在单击按钮时使用 MFMailComposeViewController 发送电子邮件。

我怎样才能做到这一点?
我使用了下面的代码。

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];

[controller setSubject:@"Email App"];

[controller setMessageBody:@"Sample email app" isHTML:NO];

[self presentModalViewController:controller animated:YES]; // App crash in this line.

[controller release];

它显示了这个警告:
'ImportingDocumentAppDelegate' may not respond to '-presentModalViewController:animated:'.

谢谢.....

最佳答案

@阿伦presentModalViewControllerUIViewController的方法所以你不能在应用委托(delegate)实例上调用它。将 UIViewController 的 View 添加到您的窗口,然后在该 View Controller 上调用此方法。

关于ios - 如何使用 MFMailComposeViewController 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8264753/

相关文章:

ios - 当我调用 CollectionView :didSelectItemAtIndexPath 时没有任何反应

php - 将现有的 PHP/MYSQL/网站转换为原生 IOS/Android 应用程序

ios - Objective-C:未显示按钮的边框颜色

ios - 如何从json存储到sqlite数据库中

iphone - 重复的 UIView

ios - 键盘约束问题

ios - 使用 Text Kit 将基线与大行高的字符对齐

IOS Core Audio - MP3 到 WAV 仅在 1 声道时工作,如何获得立体声?

ios - 如何在 Objective-C 中压缩、解压缩文件(支持 arm64)

c++ - sprite在cocos2d-x中无法移动