8

我希望能够在我的应用程序中使用iPhones Mail.app,这样我的用户就可以在不离开应用程序的情况下发送共享电子邮件。我知道3.0使这成为可能。iPhone - MessageUI - 找不到框架消息

我已经正确添加框架,通过点击我的框架文件夹 - >添加现有的框架。

已将此添加到ViewController中的头文件我想Mail.app出现英寸

#import <MessageUI/MessageUI.h> 

我弹出一个UIAlert并在最后,我拨打以下功能,有显示出来没有错误在我的代码中。我是否必须在Interface Builder内部做些额外的事情?错误消息是下面

-(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 
    NSString * emailSubject = [[NSString alloc] initWithFormat:@"iPhone Subject Test"]; 
    [picker setSubject:emailSubject]; 


    NSString * content = [[NSString alloc] initWithFormat:@"iPhone Email Content"]; 

    // Fill out the email body text 
    NSString *pageLink = @"http://mugunthkumar.com/mygreatapp"; // replace it with yours 
    NSString *iTunesLink = @"http://link-to-mygreatapp"; // replate it with yours 
    NSString *emailBody = 
    [NSString stringWithFormat:@"%@\n\n<h3>Sent from <a href = '%@'>MyGreatApp</a> on iPhone. <a href = '%@'>Download</a> yours from AppStore now!</h3>", content, pageLink, iTunesLink]; 

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

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

    [self presentModalViewController:picker animated:YES]; 
    [picker release]; 
    [content release]; 
    [emailSubject release]; 


} 

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    [self dismissModalViewControllerAnimated:YES]; 
} 

我的错误信息:

ld: framework not found Message 
collect2: ld returned 1 exit status 

我跟着这个教程: http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email/

+0

请参阅http://stackoverflow.com/questions/3352664/how-to-add-existing-frameworks-in-xcode-4 – Stan 2011-12-10 21:18:58

回答

18

做了一些研究后,我发现我使用的教程非常好!代码没有错误,我的问题是我将MessageUI框架添加到我的项目中的方式。

错误的方法。 按住Ctrl并点击框架文件夹并选择添加 - >现有框架。

正确的方法。 在xcode屏幕左侧的文件面板中打开“目标”,双击您的项目名称。一个新的窗口将会弹出,在新窗口的底部可以添加一个新的链接库,点击左下角的小加号添加一个。向下滚动到MessageUI并选择添加。

如果您已经以错误的方式添加了MessageUI框架,只需简单地将其删除并以正确的方式继续。如果仍然不起作用,请关闭xcode,重新启动并重新构建应用程序。

经过许多小时寻找答案,这是什么对我有用。

0

器命令行输出会告诉你很多关于什么Xcode是使用尝试并构建您的二进制文件,包括框架包含路径和链接器在构建中包含的框架。从那里你将能够看到XCode正在使用什么,以及你的设置中可能会丢失什么。命令行输出可以在Build Results窗口的输出窗格之一中找到。