【发布时间】:2014-10-30 12:21:15
【问题描述】:
我在 IOS8 上的自动布局有问题,我可以重新创建的最简单的情况是一个简单的 tableView。我设置了一个静态单元格,然后简单地添加一个标签。
我的目标是让标签在很大程度上填满空间,所以我对标签有三个约束......
- 在超级视图中垂直居中(我认为这很好)
- 将标签尾边距设置为 30(相对于 superview)
- 将标签前导边距设置为 30(相对于 superview)
这一切都很好,完美运行,没有重大问题或警告(它确实警告零高度,但我认为这不是什么大问题)
现在......如果我添加一个披露指标,它就会崩溃。它看起来仍然不错,但我得到以下信息:
2014-10-30 15:51:46.358 ContraintIssue[25572:1586028] 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:0x7fd3f3d23390 UITableViewCellContentView:0x7fd3f3d226f0.trailingMargin == UILabel:0x7fd3f3d227e0'Label'.trailing + 30>",
"<NSLayoutConstraint:0x7fd3f3d235f0 UILabel:0x7fd3f3d227e0'Label'.leading == UITableViewCellContentView:0x7fd3f3d226f0.leadingMargin + 30>",
"<NSLayoutConstraint:0x7fd3f53b73b0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7fd3f3d226f0(38)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fd3f3d23390 UITableViewCellContentView:0x7fd3f3d226f0.trailingMargin == UILabel:0x7fd3f3d227e0'Label'.trailing + 30>
我不明白为什么添加指标会导致这样的问题,这与数字的规模无关,我已经尝试了很多。
有什么想法吗?
现实世界的例子是一个单元格,它有一个标签(标签),然后是另一个标签或一个包含可以通过遵循公开设置的值的文本视图。所以第一个标签的大小是固定的,理想情况下,第二个标签应该是最大的,但如果需要,可以截断文本。
(请参阅添加联系人中的“铃声”或“振动设置”,了解我想要实现的目标)
非常感谢,
李。
【问题讨论】:
-
我遇到了同样的问题。一切似乎都运行良好,但警告就在那里。如果我删除披露指示符,一切正常。有什么运气吗?
-
我遇到了同样的问题,虽然我无法使用情节提要解决此问题,但通过在代码中定义 UITableViewCell 子类的布局约束,我可以让附件类型正常工作!
标签: ios objective-c uitableview ios8