自动布局约束警告“将尝试通过打破约束来恢复”

7
我正在尝试实现一条新闻的动态流(类似于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.

您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - Daniel Farrell
正如@boyfarrell所指出的,我简要概述了您的限制,它们可能不是您期望的。在Y轴上只有454个点被计算在内,如果PFImageVIew应该具有相同的宽度/高度,则x轴将为400个点宽。尽管在那时,它将超出某些屏幕的范围。关于自动布局的快速说明:尽管存在这些消息,但东西似乎仍然可以正常工作,但实际上可能会导致非常意外的结果。操作系统正在做出最佳猜测,但那并不总是正确的猜测。 - Louis Tur
1个回答

16

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


这个技巧还修复了地图视图旋转时“边缘插图”。bottom == MKMapView的错误。 - malhal
你刚刚拯救了我的一天!现在日志里没有警告,我感到非常高兴 :) - Nicolas Manzini
上帝保佑你! - Mark Kazakov

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接