繁体   English   中英

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

[英]Unable to simultaneously satisfy constraints When trying to load xib file

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

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的约束已根据您的要求与mainView一起使用。

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

  1. UIImage:top,bottom,前导wrt mainView和恒定宽度,或者您可以将容器的水平中心,前导,高度,宽度指定为中心。

  2. UIButton:顶部,底部,尾随wrt mainView和恒定宽度,也可以将容器的水平居中位置,行距,高度,宽度给定。

  3. UILabel:将尾随且水平居中放置到容器就足够了,但是您也可以指定高度。 UILabel可以根据您只需要指定x和y坐标的文本字体大小自动获取高度和宽度。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM