iphone - 尝试发送电子邮件,收到 "use of undeclared unidentified MFMailComposeViewController"

标签 iphone

我正在尝试在我的应用程序中发送电子邮件。我正在尝试使用 MFMailComposeViewController 对象,但收到一条错误消息,指出它是“未声明的标识符”

代码:

-(IBAction) aContact: (id) sender;
{


    if([MFMailComposeViewController canSendMail]){

        MFMailComposeViewController *mailCtrl = [[[MFMailComposeViewController alloc] init] autorelease];
        [mailCtrl setSubject:@"Your TellaFortune Card Reading"];
        //  [mailCtrl setToRecipients:[NSArray arrayWithObject:@"drblyer@cameosurgery.com"]];
        mailCtrl.mailComposeDelegate = self;

        NSString *send;
        send=[ NSString stringWithFormat: @"%@ %@",content,@"\n \n By www.TellaFortune.com"];
        [mailCtrl setMessageBody: send  isHTML: false];

        [self presentModalViewController:mailCtrl animated:NO];
        //      [mailCtrl release];

    }
    else
    {
        UIAlertView *alert=[[ UIAlertView alloc]
                            initWithTitle:@"Cannot send email"
                            message: @"Please check internet connection and email set up"
                            delegate: self
                            cancelButtonTitle:@"Ok"
                            otherButtonTitles: nil];

        [alert show];
    }

}

最佳答案

将框架“MessageUI.framework”导入到您的项目中,并在 .h 文件中添加

#import <MessageUI/MessageUI.h>

关于iphone - 尝试发送电子邮件,收到 "use of undeclared unidentified MFMailComposeViewController",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22029842/

相关文章:

iphone - MapKit多个引脚相同坐标,不同信息选择

ios - 有没有办法为 UICollectionView 中的特定部分应用自定义流布局?

iphone - 从 UITextView 中删除底部空间

iphone - iOS 设备调试控制台长度

iphone - 使用 AVCaptureSession 录制的视频帧

iphone - 如何在Xcode中用+替换空格

iphone - 刷新自定义 tableView 中的单元格

ios - Objective-C/iPhone 'Hello World' 应用程序的显示不正确

iphone - 如何将 DTCoreText 集成到新项目中?

iphone - iOS 上的 http GET