Objective c 必须两次重新加载tableView数据才能更新约束

Objective c 必须两次重新加载tableView数据才能更新约束,objective-c,uitableview,autolayout,uicollectionview,constraints,Objective C,Uitableview,Autolayout,Uicollectionview,Constraints,我有UITableViewCell,里面有UICollectionView。所有约束都已设置。我的单元格中有一个dataSource属性。我的数据源上的Setter - (void)setDataSource:(id<MyCellDataSource>)dataSource { self->_dataSource = dataSource; [self.collectionView reloadData]; [self updateTagsWrapper

我有
UITableViewCell
,里面有
UICollectionView
。所有约束都已设置。我的单元格中有一个
dataSource
属性。我的数据源上的Setter

- (void)setDataSource:(id<MyCellDataSource>)dataSource
{
    self->_dataSource = dataSource;
    [self.collectionView reloadData];
    [self updateTagsWrapperConstraint];
}

- (void)updateTagsWrapperConstraint
{
    CGFloat height = self.collectionView.collectionViewLayout.collectionViewContentSize.height;
        self.tagsWrapperHeightConstraint.constant = height;
}
如果我不执行此操作,我的手机将在再次获取数据后更新她的身高


另外,我还有一个控制器,可以正常工作。帮帮我。提前谢谢你,阿泰姆。对不起,我的英语很差。

还需要一个aswer还需要一个aswer
[self.tableView reloadData];
[self.tableView setNeedsLayout];
[self.tableView layoutIfNeeded];
[self.tableView reloadData];