removeConstraint 无效
相关代码:
[self.scrollView removeConstraint:self.introduceTitleLabelTopConstraint];
NSLayoutConstraint* constraint = [NSLayoutConstraint constraintWithItem:self.introduceTitleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.scrollView attribute:NSLayoutAttributeTop multiplier:1 constant:0];
[self.scrollView addConstraint:constraint];
相关日志:
其中倒数第二行是我新增的约束,最后一行是我删除的约束,这个日志为什么还要打印我已经删掉的约束?
2016-09-18 12:03:15.206 GamePlatform[48552:616181] 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.
(
"<NSLayoutConstraint:0x7f8612190d90 UIImageView:0x7f86126062c0.top == UIView:self.noticeContainer.top>",
"<NSLayoutConstraint:0x7f86121c60b0 UIView:self.noticeBackgroundView.top == UIImageView:0x7f86126062c0.top + 15>",
"<NSLayoutConstraint:0x7f86121c6100 UIView:self.noticeContainer.bottom == UIView:self.noticeBackgroundView.bottom>",
"<NSLayoutConstraint:0x7f861260b0a0 UIView:self.noticeContainer.top == UIScrollView:self.scrollView.top>",
"<NSLayoutConstraint:0x7f86105e2550 ZLIconLabel:self.introduceTitleLabel.top == UIScrollView:self.scrollView.top>",
"<NSLayoutConstraint:0x7f86121c0550 ZLIconLabel:self.introduceTitleLabel.top == UIView:self.noticeContainer.bottom>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f86121c60b0 UIView:self.noticeBackgroundView.top == UIImageView:0x7f86126062c0.top + 15>
还有个问题就是,虽然界面上显示是正确的,为什么会出现 'Unable to simultaneously satisfy constraints.' 错误?
而且提示的 breaking constraint 跟我要修改的约束没有任何关联。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
backButton.translatesAutoresizingMaskIntoConstraints = false
constLabelTop.active = false
NSLayoutConstraint(item: label, attribute: .CenterY, relatedBy: .Equal, toItem: backButton, attribute: .CenterY,multiplier: 1, constant: 0).active = true
self.view.layoutIfNeeded()
https://stackoverflow.com/que...