Я использую демо о UIScrollView, и я хочу, чтобы присоединять UIView в UIView после UIScrollView инициализации, как: я нажимаю кнопку, чем есть новый UIView в нижней части UIScrollView. Поэтому я пишу такой код:Append UIView в UIScrollView после инициализации с помощью масонства
- (void)clickButton{
UIView *new = [[UIView alloc]init];
new.backgroundColor = [UIColor blueColor];
new.mas_key = @"newView";
[self.scrollView.contentView addSubview:new];
[new mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.scrollView.lastBottom);
make.left.equalTo(@0);
make.right.equalTo(self.scrollView.contentView.mas_right);
make.height.equalTo(@50);
}];
self.scrollView.lastBottom = new.mas_bottom;
[self.scrollView.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.scrollView.lastBottom);
}];
}
Но есть еще ошибка, как
MASLayoutConstraint:0x7f97f431b360 UIView:content.bottom == UIView:newView.bottom
MASLayoutConstraint:0x7f97f4341400 UIView:newView.top == UIView:newView.bottom
MASLayoutConstraint:0x7f97f4341bb0 UIView:newView.height == 50
MASLayoutConstraint:0x7f97f4315390 UIView:content.bottom == UIView:newView.bottom
Will attempt to recover by breaking constraint
MASLayoutConstraint:0x7f97f4341bb0 UIView:newView.height == 50
Это означает, что я didnot обновить ограничение после update.How, чтобы решить эту проблему?
Я использую масонство (рамки об Autolayout), если я удалю 'self.scrollView.lastBottom = new.mas_bottom;', есть блок нового UIView. Но я не могу перейти на новый UIView – Creator