【问题标题】:autolayout center X constraints flips in RTL in iOS 9iOS 9 中 RTL 中的自动布局中心 X 约束翻转
【发布时间】:2016-01-28 05:06:20
【问题描述】:

我在一个视图中有 2 个按钮,以下是 RTL 的屏幕工作正常:

在 RTL 中,它会翻转两者并显示如下:

我无法通过取消选中尊重语言方向来停止翻转

我添加了这样的约束:

它在 iOS 8 上运行良好我想阻止它们在 iOS 9 上自动翻转,有什么指导吗?

【问题讨论】:

    标签: ios autolayout ios9


    【解决方案1】:

    设置superview的语义内容属性为Force Left-To-Right。

    【讨论】:

      【解决方案2】:

      或者您可以在 appDelegate 中使用它,

      -(BOOL) isGreaterIOSVersion:(NSString*) version
      {
          NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
          if ([systemVersion compare:version options:NSNumericSearch] != NSOrderedAscending) {
              return YES;
          }
          return NO;
      }
      

      在 didFinishLaunchingWithOptions 函数中添加以下代码

      if([self isGreaterIOSVersion:9.0]) {
              [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
          }
      

      它将删除 RTL

      【讨论】:

      • 已经使用了,在那个代码之后会产生错误:)
      • 请不要这样做。不支持在UIViewappearance 代理上设置semanticContentAttribute,并且在大多数情况下不会做正确的事情。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-05
      • 2015-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多