4

如何在我的语言文件中添加换行符以用于MFMailComposeViewController? \n确实对我有用。正常单击返回键的中断具有相同的结果,没有换行符!


我的文件:

"Body_eMail"= "Hello, here is some text.\n\nLorem ipsum alsu.\n\nAnd some text, more...";

我想:

你好,

这是一些文字。Lorem ipsum 也一样。

还有一些文字,更多...


这适用于 UILabel (正如下面提到的@lawicko),但是当添加到 a 时MFMailComposeViewController\n字符会内联显示,如下所示:

Hello, here is some text.\n\nLorem ipsum alsu.\n\nAnd some text, more...

什么是正确的方法?

4

2 回答 2

6

首先确保您MFMailComposeViewControllerisHTML:YES设置。

MFMailComposeViewController *emailView = [[MFMailComposeViewController alloc] init];
NSString *emailBody = NSLocalizedString(@"Email Body", @"");
[emailView setMessageBody:emailBody isHTML:YES];

[self presentModalViewController:emailView animated:YES];

在你的Localizable.strings你必须使用 HTML<br />标签来产生换行符。

"emailBody" = "Hello, here is some text.<br /><br />Lorem ipsum alsu.<br /><br />And some text, more...";

在此处输入图像描述

于 2012-03-30T02:58:40.877 回答
2

如果您在 UITextView 中显示文本,则添加\n有效。如果您设置适当的numberOfLines在 UILabel 中显示文本,它也可以工作。我刚刚在 iOS5 模拟器和装有 iOS 5.0.1 的 iPod 上对其进行了测试。

于 2012-02-22T12:42:52.167 回答