[self.view addSubview:self.scrollView];
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view.mas_top).with.offset(.0);
make.left.equalTo(self.view.mas_left).with.offset(0.0);
make.right.equalTo(self.view.mas_right).with.offset(0.0);
make.bottom.equalTo(self.view.mas_bottom).with.offset(0.0);
}];
[self.scrollView addSubview:self.contentView];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.scrollView);
make.width.equalTo(self.scrollView);
}];
[self.contentView addSubview:self.cycleScrollView];
[self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView.mas_top).with.offset(.0);
make.left.equalTo(self.contentView.mas_left).with.offset(0.0);
make.right.equalTo(self.contentView.mas_right).with.offset(0.0);
make.height.equalTo(@(SCREEN_WIDTH/3));
}];
[self.contentView addSubview:self.collectionView];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.cycleScrollView.mas_bottom).with.offset(5.0);
make.left.equalTo(self.contentView.mas_left).with.offset(5.0);
make.right.equalTo(self.contentView.mas_right).with.offset(-5.0);
make.height.equalTo(@(self.collectionViewCellHight * number));
}];
[self.contentView addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.collectionView.mas_bottom).with.offset(5.0);
make.left.equalTo(self.contentView.mas_left).with.offset(5.0);
make.right.equalTo(self.contentView.mas_right).with.offset(-5.0);
make.height.equalTo(@(SCREEN_WIDTH/3 * [self.categoryItems count] + HEADERVIEWHIGHT));
}];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.tableView.mas_bottom).with.offset(50.0);
}];
和砌体警告:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<MASLayoutConstraint:0x7f93031d8880 UITableView:0x7f930489b800.height == 415>",
"<MASLayoutConstraint:0x7f930342c990 UITableView:0x7f930489b800.height == 290>"
)
Will attempt to recover by breaking constraint
我在scrollview中创建了一个contentView,在contentView中创建了所有其他视图。但是collectionView和tableView的高度会改变,
所以结果出错了。我的问题是当子视图的高度发生变化时,我应该怎么做才能解决这个问题?谢谢。
编辑:
当 tableview 的数据源发生变化时,从 2 变为 3,但 tableview 的高度没有显示正确的高度。