Silence "Views without any layout constraints may clip their content" on a specific view controller that has preferredContentSize set

23,492

Solution 1

I had a single warning saying the same thing.

Editor > Resolve Auto Layout Issues > Add Missing Constraints

worked for me. If it doesn't for you, something else under "Resolve Auto Layout Issues" might work.

Solution 2

For me what worked was the reposition the elements: Drag them again into position and drag their height and width to the desired size again. Then click on "Resolve Auto Layout Issues" and click on "Reset to Suggested Constraints".

Solution 3

Since no one answered this, here is how I fixed it. For each view on the form change the Layout option from Automatic to "Translates Mask Into Contraints". If you want it anchored to the upper left corner, select the top an left red handles and leave the lower and right unchecked.

Share:
23,492
Tom Shen
Author by

Tom Shen

Hi, I am Tom. I like to tinker around with Macs and sometimes Windows. I can code in Swift, Objective-C, C, and C++.

Updated on June 01, 2020

Comments

  • Tom Shen
    Tom Shen almost 4 years

    I have a view controller that's fixed size (it can not be resized). This specific view controller is presented as a sheet in a window, I disabled the resizing by setting preferredContentSize. Since it can't be resized anymore, I left the view without any constraint. However, when I build the app, I got a lot of warnings that says :

    Views without any layout constraints may clip their content or overlap other views.
    

    I do know that if you don't add any constraints in a standard window it will clip when it is resized. However, resizing is disabled on my specific window so that I know it won't happen. Is there a way to silence this warning? There are a lot of views on this specific view controller and it's blocking other useful warnings that I may encounter in the issues navigator.

    This view controller is presented through a "Sheet" segue.