Line break in Localizable.strings for MFMailComposeViewController

How can I add line breaks in my language file for use in MFMailComposeViewController ? Work \n for me. A break with a normal click on the return key has the same result, no line breaks!


My file:

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

I want to:

Hello,

here is the text. Lorem ipsum alsu.

And some text, more ...


This works fine for UILabel (like @lawicko, mentioned below), but when added to MFMailComposeViewController the \n characters appear in a string, as shown below:

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

What is the right way?

+4
source share
2 answers

First make sure your MFMailComposeViewController has isHTML:YES .

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

In Localizable.strings you must use the HTML tag <br /> to create line breaks.

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

enter image description here

+6
source

Adding \ n works if you display text in a UITextView. It also works if you display text in a UILabel, if you set the corresponding numberOfLines . I just tested it on iOS5 simulator and iPod with iOS 5.0.1.

+1
source

Source: https://habr.com/ru/post/1397739/


All Articles