第一弹 - 资源福利版.apk
萌猫导航
首页 » 技术 » iOS

使用 UIViewAlertForUnsatisfiableConstraints 捕捉autolayout 约束冲突

作者: 二琴 来源: 怪哈哈网 日期: 2016-09-20 16:11:58 人气: -

很多时候我们会遇到约束冲突的问题、但是因为苹果只会在log中提示冲突、且这些冲突很难去理解、所以遇到冲突、也很难发现到底是哪里出了问题、但是苹果还是提供了方法、去debug的。 
我们来看冲突的log:

2015-08-26 14:29:32.870 Auto Layout Cookbook[10208:1918826] 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:0x7b58bac0 'Label Leading' UILabel:0x7b58b040'Name'.leading == UIView:0x7b590790.leadingMargin>",    "<NSLayoutConstraint:0x7b56d020 'Label Width' H:[UILabel:0x7b58b040'Name'(>=400)]>",    "<NSLayoutConstraint:0x7b58baf0 'Space Between Controls' H:[UILabel:0x7b58b040'Name']-(NSSpace(8))-[UITextField:0x7b589490]>",    "<NSLayoutConstraint:0x7b51cb10 'Text Field Trailing' UITextField:0x7b589490.trailing == UIView:0x7b590790.trailingMargin>",    "<NSLayoutConstraint:0x7b0758c0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7b590790(320)]>")

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7b56d020 'Label Width' H:[UILabel:0x7b58b040'Name'(>=400)]>

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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

里面写了

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

这就意味着、我们可以通过symbolic breakpoint 来捕捉冲突、如何来设定呢?平时管理断点的地方、点击加号、addMake a symbolic breakpoint atUIViewAlertForUnsatisfiableConstraints to catch this in the debugger.然后在symbol内容填上UIViewAlertForUnsatisfiableConstraints、如果出现冲突、系统会自动停留在断点处、还是蛮好用的。 
使用 UIViewAlertForUnsatisfiableConstraints 捕捉autolayout 约束冲突

使用 UIViewAlertForUnsatisfiableConstraints 捕捉autolayout 约束冲突 
更多断点知识、可以参考cocoa的文章只会左键断点?是时候试试这样那样断点了


转载请注明文章来源(欢迎分享): http://www.guaihaha.com/ios/10989.html

怪哈哈动漫图库
关于怪哈哈
怪哈哈是一个集搞笑,美女,动漫,游戏,技术等为核心的综合性网站!
联系我们
商务洽谈、广告合作、友情链接、侵权举报,这些都可以联系我们哦!
关于我们 - 联系我们 - 广告服务 - 免责申明   
本站文字和图片均为严格审查筛选收藏,均收集整理于互联网,其著作权归原作者所有,如果有侵犯您权利的照片,请来信告知,我们将及时撤销相应文字和图片.
Copyright @2014-2020 怪哈哈网 All Rights Reserved.
【谢谢大家一直支持贵站】