bbu*_*s21 8 email iphone frameworks uiviewcontroller mfmailcomposeviewcontroller
我希望能够在我的应用程序中使用iPhone Mail.app,这样我的用户就可以在不离开应用程序的情况下发送共享电子邮件.我知道3.0使这成为可能.
我通过ctrl单击我的框架文件夹 - >添加现有框架来正确添加框架.
将此添加到我希望Mail.app出现的viewcontroller的头文件中.
#import <MessageUI/MessageUI.h>
Run Code Online (Sandbox Code Playgroud)
我弹出一个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];
}
Run Code Online (Sandbox Code Playgroud)
我的错误信息:
ld: framework not found Message
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我遵循了这个教程:http: //blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email/
bbu*_*s21 18
做了一些研究后我发现我使用的教程非常好!代码没有错误,我的问题是我将MessageUI Framework添加到我的项目中的方式.
错误道. 按住Ctrl键并单击frameworks文件夹,然后选择add - > existing frameworks ..
正确的方式. 在xcode屏幕左侧的文件面板中打开"目标",双击项目名称.将弹出一个新窗口,在新窗口的底部,您可以添加一个新的链接库,通过单击左下角的小加号添加一个.向下滚动到MessageUI并选择Add.
如果您已经以错误的方式添加了MessageUI Framework,只需删除它并继续正确的方式.如果仍然无效,请尝试关闭xcode,重新启动并重建应用程序.
经过几个小时的寻找答案,这对我有用.
| 归档时间: |
|
| 查看次数: |
10683 次 |
| 最近记录: |