适用于RTL语言的iPhone上的翻转布局 [英] Flip layout on iPhone for RTL languages

查看:48
本文介绍了适用于RTL语言的iPhone上的翻转布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题:

我已将我的应用程序本地化为阿拉伯语.(实际上,它与常规本地化略有不同,因为我有不同的目标,每种语言都有一个目标.)

I've localized my application in arabic. (It's actually slightly different than regular localization, as I have different targets, one for each language).

在模拟器上,由于自动布局和约束的前/尾部分,视图已正确翻转,但是我似乎无法在设备上获得相同的结果. AutoLayout + RTL + UILabel文本对齐显示了模拟器上翻转视图的示例.

On the simulator, the view is properly flipped, thanks to Auto-Layout and the leading / trailing part of the constraints, but I can't seem to get the same result on a device. AutoLayout + RTL + UILabel text alignment shows an example of a flipped view on the simulator.

我还在《自动版式指南》中找到了支持的指示:«

I've also found indication that it is supported in the Auto-Layout Guide : « The attributes leading and trailing are the same as left and right for left-to-right languages such as English, but in a right-to-left environment such as Hebrew or Arabic, leading and trailing are the same as right and left ». This lets me think that it is supposed to flip view, as it does on the simulator.

我在模拟器上的方案中使用了 -AppleLanguages(ar_SA),因此会翻转视图,但无法在设备本身中找到正确的设置来执行相同的操作.将语言和区域格式设置为阿拉伯语似乎没有多大帮助.那是在iPhone 4S,iOS 7.0.4上

I use -AppleLanguages (ar_SA) in my scheme on the simulator, which thus flips the view, but fail to find the proper setting in the device itself to do the same thing. Setting the language and Region Format to Arabic doesn't seem to help much. That is on an iPhone 4S, iOS 7.0.4

TLDR:我应该在实际的iPhone设备上将其更改为处于阿拉伯环境"并具有翻转视图的设置,还是我缺少什么才能在模拟器中翻转而不在设备上翻转?

TLDR: What setting should I change on an actual iPhone device to be in an « Arabic environment » and have a flipped view, or what am I missing so that it flips in the simulator but not on the device ?

推荐答案

最终添加了以下内容:

int main(int argc, char *argv[]) {
    @autoreleasepool {
#if TARGET == TARGET_AR
        NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:[NSArray arrayWithObject:@"ar-SA"] forKey:@"AppleLanguages"];
        [defaults synchronize];
#endif
        return UIApplicationMain(argc, argv, NSStringFromClass([SNFIdleDetectorApplication class]), NSStringFromClass([SNFAppDelegate class]));
    }
}

尽管我确实发现这种丑陋.

Though I do find this kind of ugly.

可能有趣的是,当设置为阿拉伯语时,设备将显示 @"ar" 作为AppleLanguages的第一个值,而不显示 @"ar-SA" 代码>.我想翻转视图不适用于 @"ar" 区域设置,尽管我不确定这是否是错误,或者某些阿拉伯国家是否编写LTR,因此不要系统地翻转视图.

Edit : It may be interesting to note that when set to Arabic, the device shows @"ar" as the AppleLanguages first value, and not @"ar-SA". I guess flipping the view doesn't work with the @"ar" locale, although I'm unsure whether that's a bug, or if some arabic countries write LTR, thus making sense not to systematically flip the view.

这篇关于适用于RTL语言的iPhone上的翻转布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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