[IOS 7.0] 我有自定义UITableViewCell并使用systemlayoutsizefittingsize:
来获取heightForRowAtIndexPath
中的高度,但它给了我这些警告,高度返回为0.所以什么我的约束错了吗?
PS:如果我使用修复高度(假设说200px),则约束有效
PPS:我使用[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]
PPPS:当我使用"<NSLayoutConstraint:0x7feafaa4df50 UITableViewCellContentView:0x7feafaa3c0b0.height == 0.5>"
[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]
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:0x7feafaa3f570 UILabel:0x7feafaa3f7d0.height == 18>",
"<NSLayoutConstraint:0x7feafaa40540 UILabel:0x7feafaa407e0.height == 25>",
"<NSLayoutConstraint:0x7feafaa42010 UILabel:0x7feafaa3f210.top == UITableViewCellContentView:0x7feafaa3c0b0.top + 18>",
"<NSLayoutConstraint:0x7feafaa421a0 UILabel:0x7feafaa3f7d0.top == UILabel:0x7feafaa3f210.bottom + 4>",
"<NSLayoutConstraint:0x7feafaa422e0 GCTLabelEllipsis:0x7feafaa3fd70.top == UILabel:0x7feafaa3f7d0.bottom - 2>",
"<NSLayoutConstraint:0x7feafaa42380 UITableViewCellContentView:0x7feafaa3c0b0.bottom == UILabel:0x7feafaa407e0.bottom + 16>",
"<NSLayoutConstraint:0x7feafaa423d0 UILabel:0x7feafaa407e0.top == GCTLabelEllipsis:0x7feafaa3fd70.bottom + 8>",
"<NSLayoutConstraint:0x7feafaa4df50 UITableViewCellContentView:0x7feafaa3c0b0.height == 0.5>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7feafaa40540 UILabel:0x7feafaa407e0.height == 25>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
修改
这是我的布局(它们在contentView下属于同一级别)
|-------------------------------------------------------------------------------------------|
| | 18 |
| -- 12 -- UIImageView (w 20) -- 12 -- UILabel - 0 lines word warp -- 6 -- UIlabel -- 8 -- |
| | 4 |
| UILabel - 1 lines trailing, h = 18 |
| | -2 |
| GCTLabelEllipsis (UILabel) - 0 line word warp |
| | 8 |
| UILabel - 1 line trailing, h = 25 |
| | 16 |
--------------------------------------------------------------------------------------------|