【问题标题】:Line Break in Localizable.strings for MFMailComposeViewControllerMFMailComposeViewController 的 Localizable.strings 中的换行符
【发布时间】:2012-02-22 07:31:35
【问题描述】:

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


我的档案:

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

我想要:

你好,

这里有一些文字。 Lorem ipsum 也一样。

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


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

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

什么是正确的方法?

【问题讨论】:

  • 这个运气好吗?我遇到了同样的问题。
  • 不....一样...我不知道。

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


【解决方案1】:

首先确保您的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...";

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 嗨,文本显示在电子邮件中(没有 uilabel 等...)...推荐应用... \n 不起作用... ;-(跨度>
    • 您是否使用 MFMailComposeViewController 发送电子邮件?
    • 是的,我愿意 ;-)-(void)displayMailComposerSheet { MFMailComposeViewController *picker = [[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 Animation:YES]; [选择器发布];}
    • 有时numberOfLines 是不够的 - 一些固定短语在分成不同的行时看起来很糟糕
    猜你喜欢
    • 1970-01-01
    • 2021-09-15
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    • 2016-09-29
    • 2011-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多