4

如何在我的语言文件中添加换行符以便在MFMailComposeViewController中使用? \n为我工作。与返回键上的正常点击有相同的结果,不会换行!MFMailComposeViewController的Localizable.strings换行


我的文件:

"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

任何这运气?我遇到了同样的问题。 – 2012-03-14 02:16:52

+0

不....它是一样的......我不知道。 – webschnecke 2012-03-14 09:24:36

回答

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..."; 

enter image description here

1

添加\ n的作品,如果你显示在UITextView中的文本。如果您设置了相应的numberOfLines,则在UILabel中显示文本时也有效。我只是用iOS 5.0.1在iOS5模拟器和iPod上测试它。

+0

嗨,文本显示在一个电子邮件(没有uilabel等...)...推荐的应用程序... \ n不工作... ;-( – webschnecke 2012-02-24 09:49:15

+0

您是否使用MFMailComposeViewController发送您的电子邮件? – lawicko 2012-02-24 11:16:42

+0

是的,我做; - ) - (无效)displayMailComposerSheet { MFMailComposeViewController *挑选器= [[MFMailComposeViewController的alloc] INIT]; picker.mailComposeDelegate = self; [picker setSubject:NSLocalizedString(@“Betr”,@“Bet”)]; //设置收件人 // NSArray * toRecipients = [NSArray arrayWithObject:@“”]; // [picker setToRecipients:toRecipients]; NSString * emailSharing = NSLocalizedString(@“Bdy”,@“Txt”); //填写电子邮件正文 [picker setMessageBody:emailSharing isHTML:YES]; [self presentModalViewController:picker animated:YES]; [picker release];} – webschnecke 2012-02-26 21:30:42