문제

How to add a newline character in localizable.strings?

I tried putting \n, but no success.

도움이 되었습니까?

해결책

Using \n should just work. With this line in "Localizable.strings":

"abc" = "foo\nbar";

and this code:

NSString *s = NSLocalizedString(@"abc", NULL);
NSLog(@"%@", s);

I get the output

2013-05-02 14:14:45.931 test[4088:c07] foo
bar

다른 팁

Just adding newlines in the .strings file also works

"str" = "Hi ,

this is .

in a new line,

";   

This works in an UILabel and UITextview as long as you set the appropriate line number:

testLabel.numberOfLines = 2;

You could also set this to 0 which is automatic line count, also you should ensure that your label is big enough to show multiple lines, or else it will be cut off.

this will not work in localizable.strings you have to create two keys and then only you can manage \n between two localizable strings during the concatination of strings.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top