我有一个带有用户输入文本的字符串变量。
然后我根据Apples示例MailComposerViewController调出一个电子邮件视图,我希望文本填充电子邮件正文。
尽可能简单地说明如何将字符串变量导入emailBody?
-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Subject Line"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"marko@test.com"];
[picker setToRecipients:toRecipients];
// Fill out the email body text
NSString *emailBody = @"Replace with string plz";
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}
更新:
项目是基于openFrameworks的
&安培;麻烦干我从c ++&的混合中推测目标c
mainApp.h包含
[picker setSubject:@"Subject Line"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"marko@test.com"];
[picker setToRecipients:toRecipients];
// Fill out the email body text
NSString *emailBody = @"Replace with string plz";
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
mainApp.mm包含
class mainApp: public ofxiPhoneApp {
public:
string mainText;
// edit
};
&安培;这一切都在硬件上运行正常,但我完全迷失在排序这个
更新2 :
仍然无法想象如何制作'访问者(getter)方法'
虽然我现在可以将用户输入字符串转换为NSString
我无法做到的是如何将其传递给MainComposerViewController文件中的代码而不会崩溃
void mainApp::draw() {
// edit
mainText = keyboard->getText();
// edit
}
...
标记
答案 0 :(得分:0)
我也是一个新手,并且遇到了很多麻烦,本教程很好地解释了它...... iPhone Tutorial: Elegant way to send formatted In-App email