首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MFMailComposeViewController混淆

MFMailComposeViewController混淆
EN

Stack Overflow用户
提问于 2013-04-29 08:07:47
回答 1查看 558关注 0票数 2

我最近学习了如何在iOS应用程序中实现电子邮件,但我对这意味着什么感到困惑。我已经附加了错误,以及代码。我正在尝试做的是让用户将信息输入到UITextField中,当他们按下发送时,它将发送到我的电子邮件。在过去的几次运行中,我得到了这些错误,我仍然很困惑。提前谢谢你!

代码语言:javascript
复制
    Information:Information:Building target 'RPSS' from 'RPSS' with configuration 'Debug' for architecture 'i386' using 'Simulator - iOS 4.3' sdk
    Error:Error:The following build commands failed:
    Error:Error:RPSS:
    Error:Error:Ld "/Users/abowmanj/Documents/Xcode projects/RPSS/build/Debug-               iphonesimulator/RPSS.app/RPSS" normal i386
    Error:Error:Build Finished with Error: 1
    Undefined symbol '_OBJC_CLASS_$_MFMailComposeViewController' referenced from:
    Error:Error:objc-class-ref-to-MFMailComposeViewController in RPSSViewController.o
    Error:Error:objc-class-ref-to-MFMailComposeViewController in SupportPage.o
    build/Debug-iphonesimulator/RPSS.app/RPSS
    Information:Information:ld: symbol(s) not found
    Information:Information:collect2: ld returned 1 exit status

代码:

代码语言:javascript
复制
-(void) showEmailModalView {
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;// <- very important step if you want feedbacks on what the user did with your email sheet

    [picker setSubject:@"Comments, Suggestions, Etc."];

    // Fill out the email body text
    NSString *emailBody = [NSString stringWithFormat: @"%@", supportInput.text];

    [picker setMessageBody:emailBody isHTML:YES]; // depends. Mostly YES, unless you want to send it as plain text (boring)

    picker.navigationBar.barStyle = UIBarStyleDefault; // choose your style, unfortunately, Translucent colors behave quirky.

    [self presentModalViewController:picker animated:YES];
    [picker release];
 }

 - (void)mailComposeController:(MFMailComposeViewController*)controller     didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
    if (result == MFMailComposeResultSent) {
        UIAlertView *sentMail = [[UIAlertView alloc] initWithTitle: @"Mail Sent:" message: @"Your mail has been sent!" delegate: self cancelButtonTitle: nil otherButtonTitles: @"Close", nil];
        [sentMail show];
        [sentMail release];
    }

    [self dismissModalViewControllerAnimated:YES];
}

-(IBAction) send : (id) sender {
    // We must always check whether the current device is configured for sending emails
    if ([MFMailComposeViewController canSendMail]) {
        [self showEmailModalView];
    }
    else {
        UIAlertView *a = [[UIAlertView alloc] initWithTitle: @"Error" message: @"Device not configured to send mail." delegate: self cancelButtonTitle: nil otherButtonTitles: @"Ok", nil];
        [a show];
        [a release];
     }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-29 08:16:44

您需要包含MessageUI框架。看一看How to "add existing frameworks" in Xcode 4?

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16269449

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档