UIViewAlertForUnsatisfiableConstraints to catch this in the debugger

使用storyboard拖拽约束collection view的时候,遇到如下的警告错误:

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:0x15eb2470 H:[UIImageView:0x15eb2690(32)]>",

    "<NSLayoutConstraint:0x15eb2b00 H:[UIImageView:0x15eb2a20(20)]>",

    "<NSLayoutConstraint:0x15eb3710 UIImageView:0x15eb2690.leading == UIView:0x15eb2310.leadingMargin + 5>",

    "<NSLayoutConstraint:0x15eb3800 H:[UIImageView:0x15eb2690]-(5)-[UILabel:0x15eb2740'2016062890']>",

    "<NSLayoutConstraint:0x15eb38f0 UIImageView:0x15eb2a20.trailing == UIView:0x15eb2310.trailingMargin + 5>",

    "<NSLayoutConstraint:0x15eb3920 H:[UILabel:0x15eb2740'2016062890']-(5)-[UIImageView:0x15eb2a20]>",

    "<NSAutoresizingMaskLayoutConstraint:0x15dbd450 h=--& v=--& H:[UIView:0x15eb2310(50)]>"

)



Will attempt to recover by breaking constraint 

<NSLayoutConstraint:0x15eb2470 H:[UIImageView:0x15eb2690(32)]>



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.

一开始以为是因为,里面的元素约束过多冲突了,发现,约束没有多,正好,最后,根据错误提示:

"<NSLayoutConstraint:0x15eb2470 H:[UIImageView:0x15eb2690(32)]>",

"<NSLayoutConstraint:0x15eb2b00 H:[UIImageView:0x15eb2a20(20)]>",
<pre name="code" class="objc">"<NSAutoresizingMaskLayoutConstraint:0x15dbd450 h=--& v=--& H:[UIView:0x15eb2310(50)]>"

 发现,横向两个元素宽度已经超过52,可是很奇怪的是,我并没有设置他们父视图的宽度为50,最后感谢伟大的stackoverflow,找到了解决办法( 
Auto layout constraints issue on iOS7 in UITableViewCell): 

self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;


一句代码解决。。。。。



题外话:错误信息提示打断点,断点我会打,运行起来也断了,但是怎么去定位这个问题呢?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值