![](/img/trans.png)
[英]Weird behaviour on joining mixed right-to-left and left-to-right language strings
[英]App interace layout direction returning left-to-right for right-to-left language
我正在尝试开发一种双语言应用程序,为此,该UI可以支持从左到右和从右到左的语言。 我已将模拟器设置切换为希伯来语,这是一种RTL语言,但它根本不会影响视图的布局(自动布局似乎已正确设置),但更重要的是,此方法(在下面的UITableViewController中):
if UIView.userInterfaceLayoutDirectionForSemanticContentAttribute(view.semanticContentAttribute) == UIUserInterfaceLayoutDirection.RightToLeft {
print("RTL")
}
else{
print("LTR")
}
打印LTR
不知道该方法是否错误或我的应用程序设置未正确配置。 这是一个屏幕截图,您可以看到我的示例项目的样子(请参见状态栏顶部的希伯来语)
我遵循Apple Docs的国际化支持,但一定错过了一些东西(除非这是一个错误)。
使用Swift 2.0和xcode 7.0.1
当布局方向改变时, semanticContentAttribute
属性是组件应如何呈现自身。 默认为未指定。 所以你总是会虚假
“LTR”
将代码更改为此,您将获得当前布局的正确打印:
if UIView.userInterfaceLayoutDirectionForSemanticContentAttribute(UIUserInterfaceLayoutDirection.Unspecified) == UIUserInterfaceLayoutDirection.RightToLeft {
print("RTL")
}
else{
print("LTR")
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.