Xcode5和iOS7:Localizable.strings中字符串中的尾随空格不再起作用 [英] Xcode5 and iOS7: trailing whitespaces in strings in Localizable.strings not working anymore

查看:263
本文介绍了Xcode5和iOS7:Localizable.strings中字符串中的尾随空格不再起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Localizable.strings 中,我定义了一个带有这样的尾随空格的字符串:

In my Localizable.strings I define a string with trailing whitespaces like this:

"%@ points  " = "%@ Punkte  ";

这在iOS6中运行得很好但是在iOS7模拟器上运行时,字符串被修剪并且尾随空格被剥离。

This worked just fine in iOS6 but when runing on an iOS7 emulator, the string is trimmed and the trailing whitespaces are stripped off.

背景:上面的字符串在标签中右对齐。我使用空格作为填充,因为我不想为UILabel创建子类或只为一个标签写一堆代码。

Background: The string above is right-aligned in a label. I use the whitespaces as a padding since I dont want to subclass UILabel or write a bunch of code for just one label.

我也尝试过使用ASCII符号,但这也是不起作用。

I also tried using ASCII signs, but this also did not work.

任何有关简单灵魂的建议都会受到赞赏。

Any suggestions for a simple soultion would be appreciated.

谢谢!

推荐答案

也许你可以尝试使用NSMutableAttributedString来解决这个问题。 。代替空格。

Perhaps you can try this workaround with NSMutableAttributedString which worked for me. The "." is put in place of the whitespace.

NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%i.", count]];


 [string addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0,string.length-1)];

 [string addAttribute:NSForegroundColorAttributeName value:[UIColor clearColor] range:NSMakeRange(string.length-1,1)];

这篇关于Xcode5和iOS7:Localizable.strings中字符串中的尾随空格不再起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆