Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange UIView-Encapsulated-Layout-Height Error

I'm making test application, so in my tableviewCell in storyboard I have imageView & webView (webview to show html-text).

I set constraints like top/left/right/height=200 for imageView, spacing=5 between them & left/right/bot for webView, so I want to calculate my webView height programmatically and then change cell's height to stretch my webView. But I got this :

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 & fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property      translatesAutoresizingMaskIntoConstraints)      (         "<NSLayoutConstraint:0x7fd6f3773f90 V:[UIImageView:0x7fd6f3773e90(200)]>",         "<NSLayoutConstraint:0x7fd6f3774280 UIImageView:0x7fd6f3773e90.top == UITableViewCellContentView:0x7fd6f3462710.topMargin>",         "<NSLayoutConstraint:0x7fd6f3774320 V:[UIImageView:0x7fd6f3773e90]-(5)-[UIWebView:0x7fd6f3462800]>",         "<NSLayoutConstraint:0x7fd6f3774370 UITableViewCellContentView:0x7fd6f3462710.bottomMargin == UIWebView:0x7fd6f3462800.bottom>",         "<NSLayoutConstraint:0x7fd6f375ee40 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fd6f3462710(205)]>"     ) 

Any suggestions?

like image 238
Zaporozhchenko Oleksandr Avatar asked Feb 09 '15 12:02

Zaporozhchenko Oleksandr


1 Answers

I usually remove this warning by lowering the priority of the constraint that AutoLayout is trying to break. So if it says:

Will attempt to recover by breaking constraint  <NSLayoutConstraint:0x7fd7c2ecb520 V:[UIView:0x7fd7c2ecd0e0(300)]> 

Go ahead and lower that one's priority to 999.

That should work.

Cheers.

like image 75
Fran Sevillano Avatar answered Oct 14 '22 03:10

Fran Sevillano