简体   繁体   English

iOS:本地化的UILabel文本未对齐

[英]iOS: Localized UILabel text is missaligned

I'm updating an app to include localization for English (base) and Spanish. 我正在更新一个应用程序,以包括英语(基础)和西班牙语的本地化版本。 On my login screen in Storyboard I have an UILabel and an UISwitch for the user to select if they want to remember the Member Id for login. 在情节提要的登录屏幕上,我有一个UILabel和一个UISwitch,供用户选择是否要记住要登录的会员ID。

在此处输入图片说明

I have added a translation for the label text in Main.strings (Spanish) file: 我在Main.strings(西班牙语)文件中为标签文本添加了翻译:

/* Class = "UILabel"; text = "Save Member ID"; ObjectID = "drT-iV-8Z7"; */
"drT-iV-8Z7.text" = "Guardar ID del miembro";

However, when I view in Spanish, the "Save Member ID" text is slightly indented. 但是,当我用西班牙语查看时,“保存会员ID”文本略有缩进。

在此处输入图片说明

I've confirmed that there is not any leading spaces, left justification is on and all of the labels have the same X coordinate. 我已经确认没有任何前导空格,左对齐方式已经打开,并且所有标签都具有相同的X坐标。 I am not seeing this behavior with any of the other localized strings. 我没有在其他任何本地化字符串中看到此行为。

Has anyone experienced this issue before? 有人遇到过这个问题吗? Thanks in advanced. 提前致谢。

Such seemingly inexplicable UI glitches can be caused by: 这种看似莫名其妙的UI故障可能是由于:

  • Categories of UILabel that your code might contain; 您的代码可能包含的UILabel 类别
  • Property changes using the appearance protocol 使用appearance协议更改属性

Check for the occurrence of these in your project. 检查项目中这些事件的发生。

The screenshot seems to indicate that you are modifying the labels with borders, rounded corners, etc. Examine your code doing these modifications. 屏幕快照似乎表明您正在修改带有边框,圆角等的标签。请检查您的代码是否进行了这些修改。 Specifically, you want to check if leftView and/or leftViewMode have been altered in any way. 具体来说,您想检查是否已以任何方式更改了leftView和/或leftViewMode

Another thing to check is a project-wide text search for this phrase. 要检查的另一件事是在整个项目范围内对该短语进行文本搜索。 It could be substituted again with the typo. 可以再次用错字代替。

我可以通过从.strings文件中删除西班牙语短语来解决此问题,然后重新创建该短语。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM