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

柔情痞子 提交于 2019-12-10 02:19:06

问题


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.


回答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.




回答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".



来源:https://stackoverflow.com/questions/51463347/silence-views-without-any-layout-constraints-may-clip-their-content-on-a-speci

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