我目前正在使用Masonry DSL設置我的iOS自動佈局的UITableViewCell。它的工作在iOS的7罰款,但在iOS 6中它的呼喊警告這樣的一堆碎約束:iOS自動佈局約束在iOS 6中損壞,但在iOS7中罰款
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-03-13 14:41:07.422 clear[754:907] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<MASLayoutConstraint:0x1ed1e180 UILabel:0x1ed18ec0.centerY == UIView:0x1ed6b2b0.centerY>",
"<MASLayoutConstraint:0x1ed00f50 UILabel:0x1ed18ec0.centerY == UIView:0x1ed6b2b0.centerY>"
)
Will attempt to recover by breaking constraint
<MASLayoutConstraint:0x1ed1e180 UILabel:0x1ed18ec0.centerY == UIView:0x1ed6b2b0.centerY>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-03-13 14:41:07.451 clear[754:907] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<MASLayoutConstraint:0x1edf0010 UIView:0x1edef170.width == UIView:0x1edef170.height * 0.75>",
"<MASLayoutConstraint:0x1ed309f0 UIView:0x1edef170.width == UIView:0x1edef170.height * 0.75>"
)
Will attempt to recover by breaking constraint
<MASLayoutConstraint:0x1edf0010 UIView:0x1edef170.width == UIView:0x1edef170.height * 0.75>
一件事,我注意到這個現象的原因的一些限制(如上圖所示)是重複的,所以iOS版不得不放棄其中一個。下面的代碼片段。任何人都可以幫助我找出問題所在,並擺脫此警告信息?
的UITableViewCell updateConstraints
- (void)updateConstraints
{
[super updateConstraints];
[self.coverImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).with.offset(20);
make.top.equalTo(self.contentView).with.offset(5);
make.bottom.equalTo(self.contentView).with.offset(-5);
make.width.equalTo(self.coverImage.mas_height).multipliedBy(0.75);
}];
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.coverImage.mas_right).with.offset(10);
make.centerY.equalTo(self.contentView).priorityLow();
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.containerView);
make.top.equalTo(self.containerView);
}];
[self.avatarImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLabel.mas_bottom).with.offset(5);
make.left.equalTo(self.containerView);
make.bottom.equalTo(self.containerView);
make.width.equalTo(@20);
make.height.equalTo(@20);
}];
[self.authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.avatarImage.mas_right).with.offset(5);
make.centerY.equalTo(self.avatarImage);
}];
[self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView).with.offset(-10);
make.top.equalTo(self.contentView).with.offset(5);
}];
}
工程就像一個魔術!嗯,不完全像魔術,因爲你的解釋對我來說很清楚。非常感謝 ;) – Andree