MFMailComposeViewController的Localizable.strings中的换行符

时间:2012-02-22 07:31:35

标签: ios xcode mfmailcomposeviewcontroller line-breaks localizable.strings

如何在我的语言文件中添加换行符以便在MFMailComposeViewController中使用? \n为我做的工作。使用返回键上的正常klick中断具有相同的结果,没有换行符!


我的档案:

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

我想:

你好,

这里有一些文字。 Lorem ipsum alsu。

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


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

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

正确的方法是什么?

2 个答案:

答案 0 :(得分:6)

首先确保您的MFMailComposeViewController设置isHTML: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...";

enter image description here

答案 1 :(得分:1)

如果在UITextView中显示文本,则添加 \ n 会有效。如果您在UILabel中显示文本,如果您设置了适当的numberOfLines,它也会起作用。我刚刚在iOS5模拟器和iPod 5.0.1上测试过它。