应用程序在iOS8 beta4中崩溃,当我在NSLayoutAttributeLeading和NSLayoutAttributeLeft属性之间为视图设置NSLayoutConstraints
当我们为所描述的组合的视图添加约束时,这种情况在所有场景中都会发生。
NSLayoutAttributeLeading and NSLayoutAttributeRight
NSLayoutAttributeTrailing and NSLayoutAttributeRight
NSLayoutAttributeLeading and NSLayoutAttributeLeft
这组代码在iOS7.0中运行良好,在iOS8 beta4和beta5中单独崩溃。
这有问题吗?或者我们不应该像我描述的那样设置约束。如果有人遇到同样的问题,请告诉我。
理论上,NSLayoutAttributeLeading和nslayoutattributelleft对于从左到右的语言模式是相同的。但是对于像阿拉伯语这样的RTL语言,NSLayoutAttributeLeading实际上意味着正确。这就是为什么你不应该尝试构造约束。NSLayoutAttributeTrailing with Left &正确的。在iOS 7中,它不会崩溃,但似乎iOS 8在这种情况下变得更加严格。
虽然以下两个工作并导致类似的行为,第二个将在iOS8中崩溃(我最后一次检查是在beta 5中)//iOS8方式(在iOS7中正常运行)
[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeLeft relatedBy:relatedBy:NSLayoutRelationEqual toItem:container attribute:NSLayoutAttributeLeft multiplier:1 constant:10.0f]
//iOS7方式(可能在iOS8中崩溃)
[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeLeading relatedBy:relatedBy:NSLayoutRelationEqual toItem:container attribute:NSLayoutAttributeLeft multiplier:1 constant:10.0f]
谢谢