尝试加载 xib 文件时无法同时满足约束条件

Unable to simultaneously satisfy constraints When trying to load xib file

我正在尝试使用 xib 文件实现 UITableView 但是当我 运行 应用程序时,我收到以下错误并且 xib 在像 iPhone4s 这样的小屏幕上正确显示
它在更大的显示尺寸下工作正常。

Screenshot of xib

任何帮助将不胜感激

错误

    2016-12-14 17:12:41.826 FoodStrock[5776:1761262] 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:0x7fcc2a6dfac0 V:[UIImageView:0x7fcc2a6e1010(63)]>",
    "<NSLayoutConstraint:0x7fcc2a617530 V:[UIImageView:0x7fcc2a6e1010]-(8)-|   (Names: '|':UITableViewCellContentView:0x7fcc2a6e1270 )>",
    "<NSLayoutConstraint:0x7fcc2a6cc3b0 V:|-(9)-[UIImageView:0x7fcc2a6e1010]   (Names: '|':UITableViewCellContentView:0x7fcc2a6e1270 )>",
    "<NSLayoutConstraint:0x7fcc2a4955a0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fcc2a6e1270(59.6667)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fcc2a6dfac0 V:[UIImageView:0x7fcc2a6e1010(63)]>

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.
2016-12-14 17:12:41.827 FoodStrock[5776:1761262] 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:0x7fcc2a6a69d0 V:[UILabel:0x7fcc2a6e1670'Address'(63)]>",
    "<NSLayoutConstraint:0x7fcc2a693820 UILabel:0x7fcc2a6e1670'Address'.bottom == UITableViewCellContentView:0x7fcc2a6e1270.bottomMargin>",
    "<NSLayoutConstraint:0x7fcc2a6e0c00 UILabel:0x7fcc2a6e1670'Address'.top == UITableViewCellContentView:0x7fcc2a6e1270.topMargin + 1>",
    "<NSLayoutConstraint:0x7fcc2a4955a0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fcc2a6e1270(59.6667)]>"
)

将您的 UIImageView 、 UILabel 、 UIButton 放在单个 UIView 中(说 mainView)。现在 mainView 约束将从 xib 视图(superView)开始,尾随,顶部底部。现在 UIImageView 、 UILabel 、 UIButton 的约束是根据你的要求w.r.t。主视图。

注意: 尽可能减少对 UIComponents 的约束,但请记住它完全满足您的要求。像这里一样,给出这样的约束:

  1. UIImage : top, bottom, Leading wrt mainView and constant width or you can horizo​​ntally center to container, leading, height, width.

  2. UIButton:顶部、底部、尾部 wrt mainView 和恒定宽度,或者您可以将水平居中设置为容器、前导、高度、宽度。

  3. UILabel:前导尾随和水平中心到容器就足够了,但你也可以给出高度。 UILabel可以根据文字的字体大小自动取高宽,你只需要指定x和y坐标即可。