How to find the crashing constraint?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 08:36:54

You read them like this:

<NSLayoutConstraint:0x11d748d0 V:    [UITextView:0xc1bb000(65)]>
 ^ Constraint type  ^ Address  ^Axis ^Description in VFL
                      (of constraint)

So this is a constraint forcing the textview to be 65 points high. In there you also have a constraint pinning this text view to 134 points from its superview's top edge:

<NSLayoutConstraint:0xa1980d0 V:|-(134)-[UITextView:0xc1bb000]   (Names: '|':UIView:0xa1afba0 )>

And a constraint pinning the Y center of the text view to the Y center of a button:

<NSLayoutConstraint:0xa199ed0 UITextView:0xc1bb000.centerY == UIButton:0x11d71cf0.centerY>

And a constraint pinning the button itself to a specific vertical location:

<NSLayoutConstraint:0xa199e50 V:[UIButton:0x11d79e70]-(61)-[UIButton:0x11d71cf0]>

It is likely that you didn't want all these constraints. Here you have two constraints that are trying to position the text view vertically (based from the button, and based on absolute spacing from the top of the superview).

Somewhere in your app you must have a view with a text field and two buttons. If you break on all exceptions you can log out the various addresses given in the log and find out the superviews and so on if you're not sure, but hopefully you'll be able to work it out from this.

Sometimes it is helpful to copy the log into a text editor and find / replace the addresses with words so that it is easier to read.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!