我希望能够在我的应用程序中使用 iPhone Mail.app,以便我的用户无需离开应用程序即可发送共享电子邮件。我知道 3.0 使这成为可能。
我已经通过按住 Ctrl 键单击我的框架文件夹 -> 添加现有框架来正确添加框架。
将此添加到 View Controller 的头文件中,我希望 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/
最佳答案
经过一些研究,我发现我使用的教程非常好!代码没有错误,我的问题是我将 MessageUI Framework 添加到项目的方式。
错误的方式。 按住 Ctrl 键单击框架文件夹并选择添加 -> 现有框架..
正确的方式。 在 Xcode 屏幕左侧的文件面板中打开“targets”,双击项目名称。将弹出一个新窗口,在新窗口的底部您可以添加一个新的链接库,通过单击左下角的小加号来添加。向下滚动到 MessageUI 并选择“添加”。
如果您已经以错误的方式添加了 MessageUI Framework,只需将其删除并按照正确的方式继续即可。如果仍然不起作用,请尝试关闭 xcode,重新启动并重建您的应用程序。
经过几个小时的寻找答案后,这对我有用。
关于iPhone - MessageUI - 找不到框架消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1376977/