如何在我的语言文件中添加换行符以便在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...
正确的方法是什么?
答案 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...";
答案 1 :(得分:1)
如果在UITextView中显示文本,则添加 \ n 会有效。如果您在UILabel中显示文本,如果您设置了适当的numberOfLines,它也会起作用。我刚刚在iOS5模拟器和iPod 5.0.1上测试过它。