Reputation: 2369
[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);
}];
and the Masonry warning :
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
I make a contentView in scrollview and all other views in the contentView.But the collectionView and the tableView's height will change,
so the result of this goes wrong.My question is when the subview's height changed, what should I do to fix this? Thanks you.
edit:
When the tableview's datasource changed, from 2 to 3, but the height of tableview does not show the right height.
Upvotes: 0
Views: 404
Reputation: 1646
I have not used Masonry-iOS-OSX, but as far as autolayout is concerned, don't give the height to scroll view (you are doing so when you connect scroll view with the top and bottom of super view), its height should be dependent on the inner views. Remove the top and bottom constraints of the scroll view and put align center to the super view. so that when the height of collection view changes it will change the height of the scroll view. Hope it resolves you problem.
Upvotes: 1