Jos*_*eph 5 uitableview nslayoutconstraint ios8
当我在iPhone上运行我的应用程序时,我收到以下错误.当我在模拟器中运行它时,我没有.如果我把它-12-|带走,那么单元格的高度就会崩溃到30像素.用户界面打破了.有人能帮帮我,告诉我为什么吗?
谢谢
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)
(
"<NSLayoutConstraint:0x170285ff0 V:|-(12)-[UIImageView:0x1741ec200] (Names: '|':UITableViewCellContentView:0x17419c7d0 )>",
"<NSLayoutConstraint:0x170286040 V:[UIImageView:0x1741ec200(200)]>",
"<NSLayoutConstraint:0x170286090 V:[UIImageView:0x1741ec200]-(12)-| (Names: '|':UITableViewCellContentView:0x17419c7d0 )>",
"<NSLayoutConstraint:0x174881f40 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x17419c7d0(224)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x170286090 V:[UIImageView:0x1741ec200]-(12)-| (Names: '|':UITableViewCellContentView:0x17419c7d0 )>
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.
Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
Unable to simultaneously satisfy constraints.
Run Code Online (Sandbox Code Playgroud)
在自定义中,UITableViewCell我定义了布局约束,如下所示:
_imgView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[imageView]-15-|" options:0 metrics:nil views:@{ @"imageView": _imgView }]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-12-[imageView(200)]-12-|" options:0 metrics:metrics views:@{ @"imageView" : _imgView }]];
Run Code Online (Sandbox Code Playgroud)
---编辑---
回应这个contentView.bounds建议:在我的UITableViewController实施中:
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 30.0f;
Run Code Online (Sandbox Code Playgroud)
所以零高度,应该不是问题.
小智 1
单元格的初始高度可能小于垂直约束。这会产生初始高度冲突,直到 contentView 的框架发生变化。
您可以使用以下方法之一解决此问题:
增加故事板中单元格的高度以最初适合内容。
将单元格 contentView 的边界更改为更大的尺寸:
self.contentView.bounds = CGRectMake(0, 0, 99999, 99999);
您可以在此自动布局问题的答案中找到更多详细信息。
更新:
“无法同时满足约束”冲突发生在尝试将单元格高度设置为 225 点的 imageView 约束与尝试将单元格高度设置为 224 点的固定高度之间。
您的 imageView 垂直约束使用 224 (12 + 200 + 12) 点。tableView分隔符使用1点。因此,像元高度需要为 225 点才能满足所有约束。
| 归档时间: |
|
| 查看次数: |
739 次 |
| 最近记录: |