NSString 新行在邮件中不起作用?

发布于 2024-12-02 00:47:43 字数 1221 浏览 1 评论 0原文

我有两个 UITextView,我想在用户发送邮件时显示它们。问题是我希望第二个文本视图中的文本显示在邮件的新行中。

我尝试过使用 NSLog,它在那里工作得很好,邮件 API 是否有问题或者为什么不能正常工作?

我的代码如下所示:

NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@\n\n%@", desc, ingredients];
NSLog(@"%@\n\n%@", desc, ingredients);

-(void)displayComposerSheet 

{ MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = 自我;

[picker setSubject:titleLabel.text];
NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@\n\n%@", desc, ingredients];
NSLog(@"%@\n\n%@", desc, ingredients);
[picker setMessageBody:emailBody isHTML:YES];


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

}

- (void)viewDidLoad {
titleLabel.text = [recipeData valueForKey:@"title"];
descriptionTextView.text = [recipeData valueForKey:@"description"];
ingredientsTextView.text = [recipeData valueForKey:@"ingredients"];
[super viewDidLoad];

}

I have two UITextViews that I want to be displayed when the user sends mail. The problem is that I want the text from the second textview to be displayed in a new line in the mail.

I've tried with NSLog and it works just fine there, is there a problem with the mail API or why is not working properly?

My code looks like this:

NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@\n\n%@", desc, ingredients];
NSLog(@"%@\n\n%@", desc, ingredients);

-(void)displayComposerSheet 

{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

[picker setSubject:titleLabel.text];
NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@\n\n%@", desc, ingredients];
NSLog(@"%@\n\n%@", desc, ingredients);
[picker setMessageBody:emailBody isHTML:YES];


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

}

- (void)viewDidLoad {
titleLabel.text = [recipeData valueForKey:@"title"];
descriptionTextView.text = [recipeData valueForKey:@"description"];
ingredientsTextView.text = [recipeData valueForKey:@"ingredients"];
[super viewDidLoad];

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

離殇 2024-12-09 00:47:43

在撰写邮件时只需使用 html 标签即可正常工作。
使用 html
标签作为新行。

NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@ <br/> <br/> %@", desc, ingredients];
// [email setMessageBody:emailBody isHTML:YES]; 
NSLog(@"%@\n\n%@", desc, ingredients);

In mail composing just use the html tags then it works fine.
Use a html <br /> tag for a new line.

NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@ <br/> <br/> %@", desc, ingredients];
// [email setMessageBody:emailBody isHTML:YES]; 
NSLog(@"%@\n\n%@", desc, ingredients);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文