2015-10-04 60 views
2

我们的应用程序支持阿拉伯语,波斯语等RTL语言。iOS中的RTL语言行为9

在iOS 9之后,导航控制器和标签栏控制器行为已被更改。我发现只有这个链接ios-9-disable-support-for-right-to-left-language为解决这个问题

我写这个代码在我的appDelegate和它工作正常,导航栏和标签栏设置为LTR。

if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) { 
    [[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight]; 
    [[UITabBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight]; 
} 

我的问题是: 我不能改变交互流行的手势方向。

enter image description here

+0

你为什么要这么做? – Fogmeister

+1

@Fogmeister,因为它的风格很差,而且对于用户体验来说不是经常性的。你可以改变语言并看看Whatsapp(他们已经处理了这个问题),但电报团队离开这个问题。 你有什么想法吗? – Mohamad

+0

这是您的意见还是您曾经与很多rtl用户谈过的话?在我工作的地方,我们花了很长时间面试用户。它确实是rtl用户想要的东西。 – Fogmeister

回答

0

如果您正在创建自定义弹出,双向您可以处理这个问题。

  1. 在.h文件中定义宏以在运行时检测它是否为RTL语言。

    限定IS_RTL [UIApplication的sharedApplication] .userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft

然后根据如果IS_RTL.Like

if (IS_RTL) 
//Do Arabic Implementation 
else 
//Do other language implementation 
创建自定义布局
  • 如果从Storyboard创建UI,对Lead或Trailing空间的设置约束以及First Item的值将为尊重语言方向
  • +0

    tnx为您的答案,但不幸的是,在OS 9之后,我们不能使用'setSemanticContentAttribute',无论如何'Respect Language Direction'对我们的对齐很有帮助,方向不起作用。 结论:我们尊重这个行为就像很多应用程序到应用商店:) – Mohamad

    1

    我用同样的问题,终于找到了解决方案

    ,你只需要在RootViewController的的viewDidLoad设置SemanticContentAttribute为navigationController.view

    挣扎:

    [self.navigationController.view setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight]; 
    [self.navigationController.navigationBar setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight]; 
    
    1

    在斯威夫特

    navigationController?.view.semanticContentAttribute = .forceRightToLeft 
    navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft