gpt4 book ai didi

iOS 本地化搞乱了 UI

转载 作者:搜寻专家 更新时间:2023-10-31 19:37:45 24 4
gpt4 key购买 nike

我有一个支持不同语言的 iOS 应用程序,它使用 LTR Storyboard 和 RTL Storyboard,并从 Plists 读取。当我在我的设备上使用英文 iOS 版本运行该应用程序时,在语言之间切换时一切看起来都很完美。但是当我将 iPhone 操作系统语言更改为 RTL 语言时。用户界面一团糟。

尤其是当我启用 Localizations 以更改主屏幕上的应用程序名称时,会发生这种情况。

知道为什么会这样吗?

例如,整个菜单都乱七八糟,它在左边,而它应该在右边,菜单项图标必须在左边,标签在右边。

LTR iOS 语言设备上的 RTL 语言即英语

RTL iOS 语言设备上的 RTL 语言 enter image description here

最佳答案

这是因为您使用了前导和尾随约束。在 LTR 环境中,leading 表示向左,而在 RTL 环境中,leading 表示向右。这是 Apple 帮助我们轻松处理 RTL/LTR 的方法:[在你的情况下,没那么多......要禁用此行为,请更改 View 的语义属性。

Semantic Content

If you lay out your views using leading and trailing constraints, the views automatically flip positions when switching between left-to-right languages (like English) and right-to-left languages (like Arabic). However, some interface elements should not change their position based on the reading direction. For example, buttons that are based on physical directions (up, down, left, and right) should always stay in the same relative orientation.

The view’s semanticContentAttribute property determines whether the view’s content should flip when switching between left-to-right and right-to-left languages.

In interface builder, set the Semantic option in the Attribute inspector. If the value is Unspecified, the view’s content flips with the reading direction. If it is set to Spatial, Playback, or Force Left-to-Right, the content is always laid out with the leading edges to the left and trailing edges to the right. Force Right-to-Left always lays out the content with the leading edges to the right and the trailing edges to the left.

关于iOS 本地化搞乱了 UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38912365/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com