视图的框架不改变

view's frame don't change

我有一个 tableview.when 重新加载数据 我将配置单元格和更新约束。在那个单元格的layoutSubviews被调用之后,但是视图的框架不能被更新

- (void)configModel:(LKSportActivityEventModel *)model {
 //some code before
   CGFloat titleWidth = 100;
   [self.activityNameView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(titleWidth);
    }];
 //some code after
}
- (void)layoutSubviews {
    [super layoutSubviews];
    [self setCorner:UIRectCornerBottomRight | UIRectCornerTopLeft
             bounds:self.activityNameView.bounds
         cornerSize:CGSizeMake(4, 4)
         targetView:self.activityNameView
              layer:self.activityNameViewShapLayer];
}

activityNameView 的边界不变

The default implementation uses any constraints you have set to determine the size and position of any subviews.

layoutSubviews 只计算其子视图的大小和位置。它没有布置整个视图子树。

UITableViewCell.layoutSubviews之后,只有content view的框架是对的

修复布局的更简单方法是在 layoutSubviews 中调用 contentView.layoutIfNeeded