使用目标C的自动布局约束支持RTL语言 [英] Using Constraints in Auto Layouts of Objective C to support RTL Languages

查看:127
本文介绍了使用目标C的自动布局约束支持RTL语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在的iOS应用程序,我正在尝试本地化的RTL语言。显然,布局需要与语言对应。

I have an app in iOS which I'm trying to localise for a RTL language. Obviously, the layout need to correspond with the language.

要开始,我试图做出按钮在一个屏幕下方的RTL语言区域设置打开应用程序时,改变它们的顺序。

To get started, I'm trying to make to buttons in the bottom of one screen to change their order when opening the app with the rtl language locale set.

我使用自动布局和我添加的按钮和拖尾方面的看法之间的约束/领先水平视图的屏幕,这是我的理解应该怎样做的主视图设置。用于制作约束拖N - 降蓝线的方法。另外,我用下面的code在我的主被另一个线程的指示:

I use auto-layouts and I added constraints between the buttons and the view regarding trailing / leading horizontal view setting with the main view of the screen, which is what I understood should be done. Used the drag-n-drop blue line method for making the constraints. Also, I used the following code in my main as instructed by another thread:

#if TARGET == TARGET_AR
        NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:[NSArray arrayWithObject:@"ar-SA"] forKey:@"AppleLanguages"];
        [defaults synchronize];
#endif

这仍然无法正常工作,并且按钮留他们在那里。任何建议如何解决此问题?

This still does not work, and the buttons stay where they were. Any suggestions on how to solve this?

感谢

推荐答案

我不知道你有使用宏来确定地区的建议,但是这是绝对错误的。

I don't know where you got the recommendation to use the macro to determine the locale, but this is absolutely wrong.

你所最有可能缺少的是一个实际的RTL本地化(它的伟大,你正在使用的基地!)。在文件导航器中选择您的项目文件,你会看到这样的事情:

What you are most likely missing is an actual RTL localization (it's great that you're using Base!). Select your project file in the file navigator and you should see something like this:

您需要做的就是添加一个实际的RTL定位。因此,点击+上面的使用基本国际化复选框,并选择阿拉伯语(AB)在弹出的菜单,然后继续出现的表单。如果你建立和电话,其中阿拉伯语为preferred语言上运行你的应用程序,约束应该翻转如您所愿!

What you need to do is add an actual RTL localization. So click the '+' above the Use Base Internationalization checkbox and pick Arabic (ab) in the popup menu and then continue in the sheet that appears. If you build and run your app on a phone where Arabic is the preferred language, the constraints should flip as you expect!

这篇关于使用目标C的自动布局约束支持RTL语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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