Xcode 6.4和Xcode 7.0 NSLayoutConstraint不一致

时间:2015-11-27 00:14:55

标签: ios objective-c xcode nslayoutconstraint

嗨问题是UILabel没有显示2个Xcode版本之间的所有文本我把灰色的框架显示得更好。

这是代码:

    _descriptionLabel.numberOfLines = 0;
    [_descriptionLabel setLineBreakMode:NSLineBreakByWordWrapping];
    _descriptionLabel.adjustsFontSizeToFitWidth = NO;
    [_descriptionLabel sizeToFit];

NSLayoutConstraint *descriptionTop = [NSLayoutConstraint constraintWithItem:self.descriptionLabel
                                                                  attribute:NSLayoutAttributeTop
                                                                  relatedBy:NSLayoutRelationEqual
                                                                     toItem:self.categoryLabel
                                                                  attribute:NSLayoutAttributeBottom
                                                                 multiplier:1
                                                                   constant:0];


NSLayoutConstraint *descriptionLeading = [NSLayoutConstraint constraintWithItem:self.descriptionLabel
                                                                      attribute:NSLayoutAttributeLeading
                                                                      relatedBy:NSLayoutRelationEqual
                                                                         toItem:self.segmentedControl
                                                                      attribute:NSLayoutAttributeLeading
                                                                     multiplier:1
                                                                       constant:0];

NSLayoutConstraint *descriptionTrailing = [NSLayoutConstraint constraintWithItem:self.descriptionLabel
                                                                       attribute:NSLayoutAttributeTrailing
                                                                       relatedBy:NSLayoutRelationEqual
                                                                          toItem:self.segmentedControl
                                                                       attribute:NSLayoutAttributeTrailing
                                                                      multiplier:1
                                                                        constant:0];

NSLayoutConstraint *descriptionBottom = [NSLayoutConstraint constraintWithItem:self.descriptionLabel
                                                                     attribute:NSLayoutAttributeBottom
                                                                     relatedBy:NSLayoutRelationEqual
                                                                        toItem:self.containerView
                                                                     attribute:NSLayoutAttributeBottom
                                                                    multiplier:1
                                                                      constant:0];



[self addConstraints:@[descriptionTop,descriptionLeading,descriptionTrailing,descriptionBottom]];

此图片来自Xcode 6.4并显示所有文字正确

enter image description here

此图片来自Xcode 7.0 text show cut

enter image description here

感谢任何评论

1 个答案:

答案 0 :(得分:0)

查看调试器是否存在违反冲突约束的警告。

您的Label已将其autoResizingMask转换为约束,并且它们与上述4个约束冲突,或者这4个与您现有的约束冲突,并且#34; self"你的。