【问题标题】:Autolayout constraints warning “Will attempt to recover by breaking constraint”自动布局约束警告“将尝试通过打破约束来恢复”
【发布时间】:2015-04-18 18:53:55
【问题描述】:

我正在尝试实现新闻提要(有点像没有 cmets 或喜欢的 instagram)。它可以工作,但 xcode 一直显示此错误。我尝试更改所有约束,但是我无法开始工作。 tableview 的高度为 475,图像的高度为 400,留出 75 用于带有标签的白色区域。

我确实用过

self.tableView.estimatedRowHeight = 475;
self.tableView.rowHeight = UITableViewAutomaticDimension;

有什么帮助吗?

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:0x174096530 UIImageView:0x1743e9000.top == UITableViewCellContentView:0x17418af80.topMargin + 13>",
    "<NSLayoutConstraint:0x1740977f0 V:[PFImageView:0x1743e8e00]-(0)-|   (Names: '|':UITableViewCellContentView:0x17418af80 )>",
    "<NSLayoutConstraint:0x174097840 V:[UIImageView:0x1743e9000]-(24)-[PFImageView:0x1743e8e00]>",
    "<NSLayoutConstraint:0x174097890 H:|-(0)-[PFImageView:0x1743e8e00]   (Names: '|':UITableViewCellContentView:0x17418af80 )>",
    "<NSLayoutConstraint:0x174097930 H:[PFImageView:0x1743e8e00]-(0)-|   (Names: '|':UITableViewCellContentView:0x17418af80 )>",
    "<NSLayoutConstraint:0x174097ac0 PFImageView:0x1743e8e00.width == PFImageView:0x1743e8e00.height>",
    "<NSLayoutConstraint:0x174097b60 V:[UIImageView:0x1743e9000(30)]>",
    "<NSLayoutConstraint:0x174092ed0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x17418af80(375)]>",
    "<NSLayoutConstraint:0x174092f20 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x17418af80(44)]>"
)


Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x174097b60 V:[UIImageView:0x1743e9000(30)]>

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.

【问题讨论】:

  • UIImageView 的高度似乎受到了过度限制。调查改变高度的约束,你应该会发现问题。
  • 正如@boyfarrell 所指出的那样,我对您的限制做了一个简短的草图,它们可能不是您所期望的。在 Y 轴上只有 475 个中的 454 个点,如果假设 PFImageVIew 具有相同的宽度/高度,则 x 轴将是 400 个点宽。虽然到那时,它会超出某些屏幕的范围。以及关于自动布局的快速说明:尽管有这些消息,但看起来它仍然有效,但实际上它可能会导致非常意想不到的结果。操作系统正在做出最佳猜测,但这并不总是正确的猜测

标签: ios objective-c xcode uitableview autolayout


【解决方案1】:

我实际上解决了将优先级从图像约束底部更改为750的问题。感谢您的帮助。

【讨论】:

  • 此提示还修复了地图视图旋转在“边缘插图”上中断的错误。底部 == MKMapView
  • 你刚刚拯救了我的一天!很高兴现在日志中没有警告:)
  • 上帝保佑你!!
猜你喜欢
  • 1970-01-01
  • 2012-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-31
  • 1970-01-01
相关资源
最近更新 更多