2011-11-25 99 views
2

我对iPhone开发非常新颖。 在我的应用程序中,我想在单击按钮时使用MFMailComposeViewController发送电子邮件。如何使用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:'. 

感谢.....

回答

0

@Arun presentModalViewControllerUIViewController的方法,所以你水湿调用它的应用程序代理实例。将UIViewController的视图添加到您的窗口,然后在该视图控制器上调用此方法。

+0

谢谢Saadnib。 – Arun

0

您的错误消息表明您正在告诉您的应用程序委托来呈现视图。您需要在UIViewController上调用该函数。

相关问题