我在一个具有动态内容的tableview单元格中有两个标签,因此表格视图单元格的高度取决于标签的高度。在每两个单元格后,表格视图单元格的约束不能正常工作标签' s文本截断。
我在自定义类
中以编程方式使用了以下代码NSMutableArray *constraintsArray = [[NSMutableArray alloc] init];
UIView *contentView = self.contentView;
[constraintsArray addObject:[NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:secondLabel attribute:NSLayoutAttributeLastBaseline multiplier:1.0 constant:8.0f]];
[constraintsArray addObject:[NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:0 multiplier:1.0 constant:114.0f]];
[constraintsArray addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[firstLabel]-15-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(firstLabel)]];
[constraintsArray addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[secondLabel]-15-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(secondLabel)]];
[self.contentView addConstraints:constraintsArray];
请提前感谢任何帮助